wijjit.elements.display.link.Link
- class wijjit.elements.display.link.Link(text, action=None, id=None, classes=None, tab_index=None, on_click=None)[source]
Inline clickable text element.
Link renders as styled text that can be focused and activated via keyboard (Enter/Space) or mouse click. When activated, it triggers the specified action.
- Parameters:
text (
str) – Link text to displayaction (
str, optional) – Action name to trigger on activationid (
str, optional) – Element identifierclasses (
strorlistofstrorsetofstr, optional) – CSS class names for stylingon_click (
callable, optional) – Callback function called when link is activated. Signature: on_click() -> Nonetab_index (int | None)
- Variables:
Examples
Create a simple link:
>>> link = Link("Click here", action="do_something")
With callback:
>>> def handle_click(): ... print("Link clicked!") >>> link = Link("Click me", on_click=handle_click)
With CSS class styling:
>>> link = Link("Danger!", action="delete", classes="text-danger")
Methods
__init__(text[, action, id, classes, ...])add_class(class_name)Add a CSS class to this element.
apply_props(props)Apply props from a VNode, skipping ephemeral props.
get_ephemeral_state()Get ephemeral state that should survive reconciliation.
get_hardware_cursor_position()Absolute screen cell where the hardware terminal cursor should park.
get_height_for_width(width)Return the height this element needs when laid out at
width.Get the intrinsic size based on text content.
handle_key(key)Handle keyboard input.
handle_mouse(event)Handle mouse input.
has_class(class_name)Check if element has a CSS class.
on_blur()Called when element loses focus.
on_focus()Called when element gains focus.
on_hover_enter()Called when mouse enters element.
on_hover_exit()Called when mouse exits element.
on_mount()Called when element is first added to the element tree.
on_unmount()Called when element is removed from the element tree.
on_update(changed_props)Called when element props are updated during reconciliation.
remove_class(class_name)Remove a CSS class from this element.
Paint memo for the skip-unchanged fast path.
render_to(ctx)Render the link element.
restore_ephemeral_state(state)Restore ephemeral state after reconciliation.
set_bounds(bounds)Set the element's screen bounds.
toggle_class(class_name)Toggle a CSS class on this element.
Attributes
captures_tabWhether this element wants the Tab key instead of focus movement.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
- get_intrinsic_size()[source]
Get the intrinsic size based on text content.
- Returns:
(width, height) - links are always single line
- Return type:
tuple[int,int]
- render_signature()[source]
Paint memo for the skip-unchanged fast path.
Captures the link text plus the style-affecting state (
focusedandhoveredare folded into_style_signature()). Seewijjit.elements.base.Element.render_signature().- Return type:
- render_to(ctx)[source]
Render the link element.
- Parameters:
ctx (
PaintContext) – Paint context with buffer, style resolver, and bounds- Return type:
None
Notes
Link styling is resolved from theme: -
link: Default link style (typically cyan underlined) -link:focus: When link has focus -link:hover: When mouse is over link