forge
Explore
Log in

Don't you dare go Hollow

project_note

Clone
★ 0

0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits

input.rs31 lines, 1.2 KiBHistoryRawDownload
1use topcoat::{
2 Result,
3 view::{Attributes, StaticClass, View, class, component, view},
4};
5
6/// Classes for the input's dimensions, border, and interaction states. Focus uses the
7/// global `:focus-visible` outline from `styles.css`.
8const INPUT: StaticClass = class!(
9 "h-8 w-full min-w-0 rounded-control border border-border bg-card px-2.5",
10 "text-sm text-foreground transition-colors duration-150 ease-out",
11 "placeholder:text-muted-foreground",
12 "file:mr-3 file:h-full file:border-0 file:bg-transparent file:text-sm file:font-medium",
13 "aria-invalid:border-destructive",
14 "disabled:cursor-not-allowed disabled:opacity-50",
15);
16
17/// A styled input, 32px tall with a hairline border.
18///
19/// Pass input attributes and event handlers through `attrs`. Extra classes are added to
20/// the input's classes. It fills its container by default. Set `aria-invalid="true"` to
21/// show the error border.
22///
23/// ```ignore
24/// view! {
25/// input(attrs: attributes! { type="email" placeholder="you@example.com" })
26/// }
27/// ```
28#[component]
29pub async fn input(#[default] mut attrs: Attributes) -> Result<impl View> {
30 Ok(view! { <input class=(class!(INPUT, attrs.remove("class"))) (attrs)> })
31}