No project description provided
Project description
reactpy-select
A minimal component wrapper for react-select.
Usage
pip install reactpy-select
from reactpy import html, component, event, run, use_state
from reactpy_select import Select, ActionMeta, Options
@component
def AppMain():
values, set_values = use_state([])
@event
def on_change(new_value: Options, actionMeta: ActionMeta):
set_values(new_value)
return html.div(
html.h2('Dropdown Example, default values (Custom styles)'),
Select(
value = values,
default_value=[options[0], options[1]],
multi=True,
onchange=on_change,
options=options
),
html.h2(f"[{', '.join([v['value'] for v in values ])}]")
)
Supported Functionality
- Current values
- Custom styling
- Default values
- IsClearable, isDisabled, isSearchable
- Multi-select
- OnChange events
- Placeholder
- Themes
Custom Styling
react-select uses a JavaScript callback mechanism to allow the component style to be customized. All aspects of the select component can be customized. See Adjusting the Styling on the react-select website for examples.
In reactpy the JavaScript is wrapped in a multi-line python string. Existing JavaScript code can be pasted into the string without modification.
STYLES = {
'option': '''(defaultStyles, state) => ({
...defaultStyles,
color: state.isSelected ? "#212529" : "#fff",
backgroundColor: state.isSelected ? "#a0a0a0" : "#212529",
})''',
'control': '''(defaultStyles) => ({
...defaultStyles,
backgroundColor: "#212529",
padding: "10px",
border: "none",
boxShadow: "none",
})''',
'singleValue': '''(defaultStyles) => ({ ...defaultStyles, color: "#fff" })''',
}
@component
def AppMain():
return Select(styles=STYLES)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
reactpy_select-0.0.4.tar.gz
(489.9 kB
view hashes)
Built Distribution
reactpy_select-0.0.4-py3-none-any.whl
(494.5 kB
view hashes)
Close
Hashes for reactpy_select-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18362fc968a52fda84f5777d870616716836589b4ee5bc72cfadf2036b59a112 |
|
MD5 | 1131528407f7626d617b5c9ea51f7e4c |
|
BLAKE2b-256 | 9db5b6dbc30f482125304eca1adf13340e0cb31b90316b5fc55eef0849028bf4 |