Populating a datatable column with switches

Is it possible to populate the column Toggle with ‘mantine’ switches?

I am using the code from the docs that show how to populate a column with dropdowns, but I cannot figure out how to get any further than this.

import dash, dash_table
import dash_html_components as html
import dash_mantine_components as dmc
import pandas as pd

app = dash.Dash(__name__)

df = pd.DataFrame({
    'A': [1, 2],
    'B': [4, 5],
    'C': [7, 8]
})

def toggle_switch():
    return dmc.Switch(
    size="lg",
    radius="sm",
    label="Enable this option",
    checked=True
)

app.layout = html.Div([
    dash_table.DataTable(
        id='datatable',
        columns=[
            {"name": i, "id": i} for i in df.columns
        ] + [{"name": "Toggle", "id": "toggle"}],
        data=df.to_dict('records'),
        editable=True,
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Hi, could you post a link to the documentation you are following?

EDIT: I think you are referring to this:

What you are trying to do is to put components into the datatable. I don’t think that will work, as the datatable expects the argument to be one of [string, number, boolean]- at least this is the error when I get if I try to put a dcc.Graph in a datatable.

yes, you are correct concerning the docs.

This shows what I am after but like you said, it is expecting a datatype that is not ‘function’

def toggle_switch():
    return dmc.Switch(
    size="lg",
    radius="sm",
    label="Enable this option",
    checked=True
)


df = pd.DataFrame({
    'A': [1, 2, 'toggle_switch()'],
    'B': [4, 5, 'toggle_switch()'],
    'C': [7, 8, 'toggle_switch()']
})

app.layout = html.Div([
    dash_table.DataTable(
        id='datatable',
        columns=[
            {"name": i, "id": i} for i in df.columns
        ] + [{"name": "Toggle", "id": "toggle", 'type':'text', 'presentation':'input'}],
        data=df.to_dict('records'),
        editable=True,
    )
])