Reflex Logo

Intro

Gallery

Hosting

Components

New

Learn

Components

API Reference

Onboarding

Api-reference

/

Component

reflex.components.component.Component

A component with style, event trigger and other props.

FieldDescription
FieldDescription
style The style of the component.
event_triggers A mapping from event triggers to event chains.
alias The alias for the tag.
is_default Whether the import is default or named.
key A unique key for the component.
id The id for the component.
class_name The class name for the component.
special_props Special component props.
autofocus Whether the component should take the focus once the page is loaded
custom_attrs custom attribute
State State class associated with this component instance
SignatureDescription
__init__(self, *args, **kwargs)Initialize the component.
_create_event_chain(self, args_spec: 'Any', value: 'Union[Var, EventHandler, EventSpec, List[Union[EventHandler, EventSpec]], Callable]') -> 'Union[EventChain, Var]'Create an event chain from a variety of input types.
get_event_triggers(self) -> 'Dict[str, Any]'Get the event triggers for the component.
__repr__(self) -> 'str'Represent the component in React.
__str__(self) -> 'str'Represent the component in React.
_apply_theme(self, theme: 'Optional[Component]')Apply the theme to this component.
apply_theme(self, theme: 'Optional[Component]')Apply a theme to the component and its children.
_exclude_props(self) -> 'list[str]'Props to exclude when adding the component props to the Tag.
_render(self, props: 'dict[str, Any] | None' = None) -> 'Tag'Define how to render the component in React.
_add_style(self, style: 'dict')Add additional style to the component.
_add_style_recursive(self, style: 'ComponentStyle') -> 'Component'Add additional style to the component and its children.
_get_style(self) -> 'dict'Get the style for the component.
render(self) -> 'Dict'Render the component.
_replace_prop_names(self, rendered_dict) -> 'None'Replace the prop names in the render dictionary.
_validate_component_children(self, children: 'List[Component]')Validate the children components.
_get_vars_from_event_triggers(event_triggers: 'dict[str, EventChain | Var]') -> 'Iterator[tuple[str, list[Var]]]'Get the Vars associated with each event trigger.
_get_vars(self, include_children: 'bool' = False) -> 'list[Var]'Walk all Vars used in this component.
_has_event_triggers(self) -> 'bool'Check if the component or children have any event triggers.
_get_custom_code(self) -> 'str | None'Get custom code for the component.
_get_all_custom_code(self) -> 'set[str]'Get custom code for the component and its children.
_get_dynamic_imports(self) -> 'str | None'Get dynamic import for the component.
_get_all_dynamic_imports(self) -> 'Set[str]'Get dynamic imports for the component and its children.
_get_props_imports(self) -> 'List[str]'Get the imports needed for components props.
_should_transpile(self, dep: 'str | None') -> 'bool'Check if a dependency should be transpiled.
_get_dependencies_imports(self) -> 'imports.ImportDict'Get the imports from lib_dependencies for installing.
_get_hooks_imports(self) -> 'imports.ImportDict'Get the imports required by certain hooks.
_get_imports(self) -> 'imports.ImportDict'Get all the libraries and fields that are used by the component.
_get_all_imports(self, collapse: 'bool' = False) -> 'imports.ImportDict'Get all the libraries and fields that are used by the component and its children.
_get_mount_lifecycle_hook(self) -> 'str | None'Generate the component lifecycle hook.
_get_ref_hook(self) -> 'str | None'Generate the ref hook for the component.
_get_vars_hooks(self) -> 'dict[str, None]'Get the hooks required by vars referenced in this component.
_get_events_hooks(self) -> 'dict[str, None]'Get the hooks required by events referenced in this component.
_get_special_hooks(self) -> 'dict[str, None]'Get the hooks required by special actions referenced in this component.
_get_hooks_internal(self) -> 'dict[str, None]'Get the React hooks for this component managed by the framework. Downstream components should NOT override this method to avoid breaking framework functionality.
_get_hooks(self) -> 'str | None'Get the React hooks for this component. Downstream components should override this method to add their own hooks.
_get_all_hooks_internal(self) -> 'dict[str, None]'Get the reflex internal hooks for the component and its children.
_get_all_hooks(self) -> 'dict[str, None]'Get the React hooks for this component and its children.
get_ref(self) -> 'str | None'Get the name of the ref for the component.
_get_all_refs(self) -> 'set[str]'Get the refs for the children of the component.
_get_all_custom_components(self, seen: 'set[str] | None' = None) -> 'Set[CustomComponent]'Get all the custom components used by the component.
_get_app_wrap_components() -> 'dict[tuple[int, str], Component]'Get the app wrap components for the component.
_get_all_app_wrap_components(self) -> 'dict[tuple[int, str], Component]'Get the app wrap components for the component and its children.

Did you find this useful?