Skip to main content

Hidden

Hides the component it is applied to. It is the inverse of the Visible modifier.

modifier Hidden

Example

import { Hidden, VStack, Text } from ui

export var main = VStack {
Text("First")
Text("Second") with {
Hidden()
}
Text("Third")
}

Hidden components still occupy their space. They just can't be interacted with and don't render onto the screen.

This is the key difference from removing a component with an if statement, which also removes the space it occupied — the remaining components close the gap:

import { VStack, Text } from ui

var show_second = false

export var main = VStack {
Text("First")
if show_second {
Text("Second")
}
Text("Third")
}

Hidden leaves a gap where the component was, while an if statement removes the space entirely

Constructor

constructor(_ hidden: Bool = true)

Conditionally hides the component.

_ hidden: Bool = true

Determines whether or not the component is hidden.

Layout Behavior

None.