snehilvj / dash-mantine-components

Plotly Dash components based on Mantine React Components
https://www.dash-mantine-components.com
MIT License
580 stars 61 forks source link

[Feature Request] Allow functions as props. #356

Open paulremo opened 1 month ago

paulremo commented 1 month ago

First of - thanks for this awesome library! It's a lot of fun to work with and it really improves the look of the Dash Apps it is used with 😃.

I have a feature request to add support for label formatting on slider elements, e.g., 40 °C for values of 40.

Background

This is supported in Mantine (see https://mantine.dev/core/slider/#control-label) and would be great to have in dmc. The docs hint at this being implemented already with the label argument (Function to generate label or any react node to render instead, set to None to disable label.), but I couldn't get it to work or find an example that explains this.

What I've tried

I guess from Python the most straight-forward way to implement this would be to support passing functions to the label argument of the Slider constructor. Currently, passing label=lambda x: x raises an Error loading layout error.

Thanks!

AnnMarieW commented 1 month ago

Hi @paulremo

Unfortunately, there is no easy solution or workaround for this one.

By default, Dash does not allow for passing functions as props. I would love to implement a solution similar to how it's done with Dash AG Grid

I'll update the feature request to a broader request: Allow functions as props. This feature would be a great addition to dash-mantine-components, as many of Mantine's components accept functions as props