Skip to main content

definitions

HttpMethod​

from dara.core.definitions import HttpMethod

class HttpMethod(Enum)

HTTP Methods enum

ErrorHandlingConfig​

from dara.core.definitions import ErrorHandlingConfig

class ErrorHandlingConfig(BaseModel)

Attributes​

  • title: str
  • description: str
  • raw_css: Optional[Any]

title​

Title to display in the error boundary

description​

Description to display in the error boundary

raw_css​

Raw styling to apply to the displayed error boundary. Accepts a CSSProperties, dict, str, or NonDataVariable.

ComponentInstance​

from dara.core.definitions import ComponentInstance

class ComponentInstance(BaseModel)

Definition of a Component Instance

Attributes​

  • uid: Optional[str]
  • js_module: ClassVar[Optional[str]]
  • py_component: ClassVar[Optional[str]]
  • js_component: ClassVar[Optional[str]]
  • required_routes: ClassVar[List[ApiRoute]]
  • raw_css: Optional[Any]
  • track_progress: Optional[bool]
  • error_handler: Optional[ErrorHandlingConfig]
  • fallback: Optional[BaseFallback]
  • id_: Optional[str]
  • for_: Optional[str]

js_module​

JS module including the implementation of the component.

Required for non-local components.

py_component​

Python unique component name. If not set, defaults to the class name.

js_component​

JS component name. If not set, defaults to the class name.

required_routes​

List of routes the component depends on. Will be implicitly added to the app if this component is used

raw_css​

Raw styling to apply to the component. Can be an dict/CSSProperties instance representing the styles tag, a string injected directly into the CSS of the wrapping component, or a NonDataVariable resoling to either of the above.


from dara.core import CSSProperties, Variable

# `style` - use the class for autocompletion/typesense
Stack(..., raw_css=CSSProperties(maxWidth='100px'))

# `style` - you can also use plain dict
Stack(..., raw_css={'maxWidth': '100px'})

# You can also provide CSS to inject directly
Stack(..., raw_css=\"\"\"
max-width: 100px;
\"\"\")

css_var = Variable('color: red;')
Stack(..., raw_css=css_var)

track_progress​

Whether to use ProgressTracker to display progress updates from a task the component is subscribed to

error_handler​

Configure the error handling for the component

fallback​

Fallback component to render in place of the actual UI if it has not finished loading

id_​

An optional unique identifier for the component, defaults to None

This has no runtime effect and are intended to help identify components with human-readable names in the serialized trees, not in the DOM

for_​

An optional for attribute for the component, defaults to None

This has no runtime effect and are intended to help identify components with human-readable names in the serialized trees, not in the DOM

CallableClassComponent​

from dara.core.definitions import CallableClassComponent

@runtime_checkable
class CallableClassComponent(Protocol)

Callable class component protocol. Describes any class with a call instance method returning a component instance.

discover​

def discover(outer_obj: DiscoverT) -> DiscoverT

Special marker for the Dara component discovery to continue the discovery.

Will make sure to statically register all encountered dependencies of marked functional component or component class. Should not be necessary in most cases, mainly useful when creating component libraries.

StyledComponentInstance​

from dara.core.definitions import StyledComponentInstance

class StyledComponentInstance(ComponentInstance)

Base class for a component implementing the common styling props

Arguments:

  • align: an alignment string, any flexbox alignment or start/center/end are accepted
  • background: set a background color on the component
  • basis: the flex-basis of the component, see css guidelines for flex-basis for formats
  • bold: whether to bold the font, defaults to False
  • border: whether to apply a border to the component, see css guidelines for formats
  • border_radius: set the radius of a components corners (i.e. round them), see css guidelines for formats
  • color: the text color of the component, defaults to inherit from document
  • font: the font to use for this component, defaults to inherit from document
  • font_size: the size of the font, defaults to inherit from document
  • gap: the gap between the flex components children
  • grow: the flex-grow of the component, see css guidelines for flex-grow for formats
  • height: the height of the component, can be an number, which will be converted to pixels, or a string
  • hug: Whether to hug the content, defaults to False
  • italic: whether to italicize the font, defaults to False
  • margin: the amount of margin to apply to the component, see css guidelines for formats
  • max_height: the maximum height of the component, can be an number or a string
  • max_width: the maximum width of the component, can be an number or a string
  • min_height: the minimum height of the component, can be an number or a string
  • min_width: the minimum width of the component, can be an number or a string
  • overflow: whether to apply overflow to the component, see css guidelines for formats
  • padding: the amount of padding to apply to the component, see css guidelines for formats
  • shrink: the flex-shrink of the component, see css guidelines for flex-shrink for formats
  • underline: whether to underline the font, defaults to False
  • width: the width of the component, can be an number, which will be converted to pixels, or a string

Attributes​

  • align: Optional[AlignItems]
  • background: Optional[str]
  • basis: Optional[Union[int, str, bool]]
  • bold: bool
  • border: Optional[str]
  • border_radius: Optional[Union[float, int, str]]
  • children: Optional[List[ComponentInstance]]
  • color: Optional[str]
  • font: Optional[str]
  • font_size: Optional[str]
  • gap: Optional[Union[float, int, str]]
  • grow: Optional[Union[int, str, float, bool]]
  • height: Optional[Union[float, int, str]]
  • hug: Optional[bool]
  • italic: bool
  • margin: Optional[Union[float, int, str]]
  • max_height: Optional[Union[float, int, str]]
  • max_width: Optional[Union[float, int, str]]
  • min_height: Optional[Union[float, int, str]]
  • min_width: Optional[Union[float, int, str]]
  • overflow: Optional[str]
  • position: Optional[str]
  • padding: Optional[Union[float, int, str]]
  • shrink: Optional[Union[int, str, float, bool]]
  • underline: bool
  • width: Optional[Union[float, int, str]]

BaseFallback​

from dara.core.definitions import BaseFallback

class BaseFallback(StyledComponentInstance)

Attributes​

  • suspend_render: Union[bool, int]

suspend_render​

Arguments:

  • suspend_render: bool or int, optional Determines the suspense behavior of the component during state updates.

  • If True, the component will always use suspense during state updates. This means the component will suspend rendering and show a fallback UI until the new state is ready.

  • If False, the component will always show the previous state while loading the new state. This means the component will never suspend during state updates. The fallback UI will only be shown on the first render.

  • If a positive integer (default is 200), this denotes the threshold in milliseconds. The component will show the previous state while loading the new state, but will suspend and show a fallback UI after the given timeout if the new state is not ready.

JsComponentDef​

from dara.core.definitions import JsComponentDef

class JsComponentDef(BaseModel)

Definition of a JS Component

Attributes​

  • js_module: Optional[str]
  • js_component: Optional[str]
  • py_module: str
  • name: str
  • type:

js_module​

JS module where the component implementation lives.

Not required for local components as they are located via dara.config.json

js_component​

JS component name. If not set, defaults to name property.

py_module​

Name of the PY module with component definition, used for versioning

name​

Name of the component, must match the Python definition and JS implementation

PyComponentDef​

from dara.core.definitions import PyComponentDef

class PyComponentDef(BaseModel)

Definition of a Python Component

Attributes​

  • func: Optional[Callable[Any]]
  • name: str
  • dynamic_kwargs: Optional[Mapping[str, AnyVariable]]
  • fallback: Optional[BaseFallback]
  • polling_interval: Optional[int]
  • render_component: Callable[Awaitable[Any]]
  • type:

render_component​

Handler to render the component. Defaults to dara.core.visual.dynamic_component.render_component

EndpointConfiguration​

from dara.core.definitions import EndpointConfiguration

class EndpointConfiguration(BaseModel)

Base class for endpoint configurations

ApiRoute​

from dara.core.definitions import ApiRoute

class ApiRoute(BaseModel)

Definition of a route for the application's api

Attributes​

  • dependencies: List[Depends]
  • handler: Callable
  • method: HttpMethod
  • url: str

Page​

from dara.core.definitions import Page

class Page(BaseModel)

Definition of a Page

Attributes​

  • icon: Optional[str]
  • content: ComponentInstanceType
  • name: str
  • sub_pages: Optional[]
  • url_safe_name: str
  • include_in_menu: Optional[bool]
  • on_load: Optional[Action]

TemplateRoute​

from dara.core.definitions import TemplateRoute

class TemplateRoute(BaseModel)

Definition of a route for the TemplateRouter

Attributes​

  • content: ComponentInstance
  • icon: Optional[str]
  • name: str
  • route: str
  • include_in_menu: Optional[bool]
  • on_load: Optional[Action]
from dara.core.definitions import TemplateRouterLink

class TemplateRouterLink(BaseModel)

Definition of a link for the TemplateRouter

Attributes​

  • icon: Optional[str]
  • name: str
  • route: str

TemplateRouterContent​

from dara.core.definitions import TemplateRouterContent

class TemplateRouterContent(BaseModel)

Definition of a content section for the TemplateRouter

Attributes​

  • content: ComponentInstance
  • route: str
  • on_load: Optional[Action]
  • name: Optional[str]

Template​

from dara.core.definitions import Template

class Template(BaseModel)

Definition of a template

Attributes​

  • layout: ComponentInstance
  • name: str