Skip to main content

Select

Struct Select 

Source
pub struct Select { /* private fields */ }
Expand description

Searchable dropdown select component

§Example

use armas_basic::components::{Select, SelectOption};

let options = vec![
    SelectOption::new("apple", "Apple"),
    SelectOption::new("banana", "Banana"),
    SelectOption::new("cherry", "Cherry"),
];
let mut select = Select::new(options)
    .selected("apple")
    .placeholder("Pick a fruit...");
select.show(ui);

Implementations§

Source§

impl Select

Source

pub fn new(options: Vec<SelectOption>) -> Self

Create a new Select component with the given options

Source

pub fn build(builder: impl FnOnce(&mut SelectBuilder)) -> Self

Build a Select using a closure-based API (prefer using Select::new())

Source

pub fn id(self, id: impl Into<Id>) -> Self

Set a unique identifier for this select component

Source

pub fn selected(self, value: impl Into<String>) -> Self

Set the initially selected value

Source

pub fn label(self, label: impl Into<String>) -> Self

Set a label for the select component

Source

pub fn placeholder(self, placeholder: impl Into<String>) -> Self

Set placeholder text shown when no option is selected

Source

pub const fn width(self, width: f32) -> Self

Set the width of the select component

Source

pub const fn height(self, height: f32) -> Self

Set the trigger height (overrides default 36px)

Source

pub const fn max_height(self, height: f32) -> Self

Set the maximum height of the dropdown menu

Source

pub const fn searchable(self, searchable: bool) -> Self

Enable or disable search functionality

Source

pub const fn font_size(self, size: f32) -> Self

Set font size (overrides height-derived default)

Source

pub const fn corner_radius(self, radius: u8) -> Self

Set corner radius (overrides default 6)

Source

pub const fn padding_x(self, padding: f32) -> Self

Set horizontal padding (overrides height-derived default)

Source

pub fn selected_value(&self) -> Option<&str>

Get the currently selected value

Source

pub fn set_selected(&mut self, value: Option<String>)

Set the selected value programmatically

Source

pub fn show(&mut self, ui: &mut Ui) -> SelectResponse

Show the Select component

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.