I’m trying to write custom Button referencing the All in One Component Document.
Here is a simple button I’ve created which has custom style. However, When I import this button, the n_clicks does not work. The callback is not called even though I pass in the id and n_clicks.
Any help appreciated.
from dash import html
import uuid
class ButtonAIO(html.Div):
class ids:
button = lambda aio_id: {
'component': 'ButtonAIO',
'subcomponent': 'button',
'aio_id': aio_id
}
ids = ids
def __init__(self,
id=None,
label='Button',
button_props=None,
):
if id is None:
id = str(uuid.uuid4())
button_props = button_props.copy() if button_props else {}
if 'style' not in button_props:
button_props['style'] = {'color': 'blue', 'background-color': '#008CBA'}
if 'children' not in button_props:
button_props['children'] = label
super().__init__([
html.Button(id=self.ids.button(id), **button_props)
])