Skip to main content

ShellContext

Struct ShellContext 

Source
pub struct ShellContext {
    pub layout: Signal<ShellLayout>,
    pub breakpoint: ReadSignal<ShellBreakpoint>,
    pub sidebar_visible: Signal<bool>,
    pub sidebar_mobile_open: Signal<bool>,
    pub mobile_sidebar: ReadSignal<MobileSidebar>,
    pub desktop_sidebar: ReadSignal<DesktopSidebar>,
    pub stack_depth: Signal<u32>,
    pub modal_open: Signal<bool>,
    pub search_active: Signal<bool>,
    pub sheet_snap: Signal<SheetSnap>,
    /* private fields */
}
Expand description

Reactive context shared across the shell tree.

Provided by AppShell via use_context_provider. Access it from any descendant component with use_shell_context.

Fields§

§layout: Signal<ShellLayout>

Current layout mode, reactive via Signal.

§breakpoint: ReadSignal<ShellBreakpoint>

Current viewport breakpoint, read-only reactive signal.

§sidebar_visible: Signal<bool>

Whether the desktop sidebar is in its expanded state (true) or not (false).

For Full: true = visible at full width, false = collapsed to zero. For Expandable: true = full width, false = rail width. For Rail: ignored (rail is always visible at its fixed width).

§sidebar_mobile_open: Signal<bool>

Whether the mobile overlay sidebar is open.

§mobile_sidebar: ReadSignal<MobileSidebar>

Mobile sidebar variant (Drawer, Rail, or Hidden).

§desktop_sidebar: ReadSignal<DesktopSidebar>

Desktop sidebar variant (Full, Rail, or Expandable).

§stack_depth: Signal<u32>

Stack navigation depth. Starts at 1 (root screen).

§modal_open: Signal<bool>

Whether the full-screen modal is currently presented.

§search_active: Signal<bool>

Whether the search overlay is currently active.

§sheet_snap: Signal<SheetSnap>

Current snap position of the persistent bottom sheet.

Implementations§

Source§

impl ShellContext

Source

pub fn is_mobile(&self) -> bool

true when the current breakpoint is compact (phone-sized viewport).

Source

pub fn toggle_sidebar(&self)

Toggles the appropriate sidebar state based on the current breakpoint.

  • On mobile: toggles sidebar_mobile_open (overlay open/closed)
  • On desktop Full / Expandable: toggles sidebar_visible
  • On desktop Rail: no-op (rail is always visible)

Takes &self because Signal has interior mutability.

Source

pub fn sidebar_state(&self) -> &'static str

Returns the data-shell-sidebar-state attribute value for the root element.

ContextValue
Mobile open"open"
Mobile closed"closed"
Desktop expanded"expanded"
Desktop Full collapsed"collapsed"
Desktop Rail (always)"rail"
Desktop Expandable collapsed"rail"
Source

pub fn push_stack(&self)

Pushes a new screen onto the stack (increments depth by 1).

Source

pub fn pop_stack(&self)

Pops the top screen from the stack (decrements depth by 1, minimum 1).

Source

pub fn reset_stack(&self)

Resets the stack to the root screen (depth 1).

Source

pub fn can_go_back(&self) -> bool

true when there is at least one screen above the root to pop back to.

Source

pub fn open_modal(&self)

Presents the full-screen modal.

Source

pub fn close_modal(&self)

Dismisses the full-screen modal.

Source

pub fn toggle_modal(&self)

Toggles the full-screen modal between presented and dismissed.

Activates the search overlay.

Deactivates the search overlay.

Toggles the search overlay between active and inactive.

Source

pub fn set_sheet_snap(&self, snap: SheetSnap)

Sets the bottom sheet to the given snap position.

Trait Implementations§

Source§

impl Clone for ShellContext

Source§

fn clone(&self) -> ShellContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ShellContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more