Rust shadcn/ui is a Rust port of shadcn/ui .
shadcn/ui is a library of beautifully designed components that you can copy and paste into your apps.
Rust shadcn/ui is available for the following frameworks:
The following frameworks are under consideration:
The tables below show the support for the various frameworks.
✅ = Supported
🟦 = Early Support
🚧 = Work In Progress
❌ = Unsupported
This project is available under the MIT license .
The Rust shadcn/ui project is part of the Rust For Web .
Rust For Web creates and ports web UI libraries for Rust. All projects are free and open source.
Displays a callout for user attention.
Yew
Default
New York
alert.rs
use lucide_yew::Terminal;
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle};
#[function_component]
pub fn AlertDemo() -> Html {
html! {
<Alert>
<Terminal class="h-4 w-4" />
<AlertTitle>{"Heads up!"}</AlertTitle>
<AlertDescription>
{"You can add components to your app using the cli."}
</AlertDescription>
</Alert>
}
}
alert.rs
use radix_yew_icons::RocketIcon;
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle};
#[function_component]
pub fn AlertDemo() -> Html {
html! {
<Alert>
<RocketIcon class="h-4 w-4" />
<AlertTitle>{"Heads up!"}</AlertTitle>
<AlertDescription>
{"You can add components to your app using the cli."}
</AlertDescription>
</Alert>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle};
#[component]
fn Usage() -> impl IntoView {
view! {
<Alert>
<Terminal class="h-4 w-4" />
<AlertTitle>{"Heads up!"}</AlertTitle>
<AlertDescription>
{"You can add components and dependencies to your app using the cli."}
</AlertDescription>
</Alert>
}
}
Yew
Default
New York
alert.rs
use lucide_yew::Terminal;
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle};
#[function_component]
pub fn AlertDemo() -> Html {
html! {
<Alert>
<Terminal class="h-4 w-4" />
<AlertTitle>{"Heads up!"}</AlertTitle>
<AlertDescription>
{"You can add components to your app using the cli."}
</AlertDescription>
</Alert>
}
}
alert.rs
use radix_yew_icons::RocketIcon;
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle};
#[function_component]
pub fn AlertDemo() -> Html {
html! {
<Alert>
<RocketIcon class="h-4 w-4" />
<AlertTitle>{"Heads up!"}</AlertTitle>
<AlertDescription>
{"You can add components to your app using the cli."}
</AlertDescription>
</Alert>
}
}
Yew
Default
New York
alert_destructive.rs
use lucide_yew::CircleAlert;
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle, AlertVariant};
#[function_component]
pub fn AlertDestructive() -> Html {
html! {
<Alert variant={AlertVariant::Destructive}>
<CircleAlert class="h-4 w-4" />
<AlertTitle>{"Error"}</AlertTitle>
<AlertDescription>
{"Your session has expired. Please log in again."}
</AlertDescription>
</Alert>
}
}
alert_destructive.rs
use radix_yew_icons::ExclamationTriangleIcon;
use yew::prelude::*;
use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle, AlertVariant};
#[function_component]
pub fn AlertDestructive() -> Html {
html! {
<Alert variant={AlertVariant::Destructive}>
<ExclamationTriangleIcon class="h-4 w-4" />
<AlertTitle>{"Error"}</AlertTitle>
<AlertDescription>
{"Your session has expired. Please log in again."}
</AlertDescription>
</Alert>
}
}
Displays content within a desired ratio.
Yew
Default
New York
aspect_ratio.rs
use yew::prelude::*;
use crate::components::ui::aspect_ratio::AspectRatio;
#[function_component]
pub fn AspectRatioDemo() -> Html {
html! {
<AspectRatio ratio={16.0 / 9.0} class="bg-muted">
<img
src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80"
alt="Photo by Drew Beamer"
class="h-full w-full rounded-md object-cover"
/>
</AspectRatio>
}
}
aspect_ratio.rs
use yew::prelude::*;
use crate::components::ui::aspect_ratio::AspectRatio;
#[function_component]
pub fn AspectRatioDemo() -> Html {
html! {
<AspectRatio ratio={16.0 / 9.0} class="bg-muted">
<img
src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80"
alt="Photo by Drew Beamer"
class="h-full w-full rounded-md object-cover"
/>
</AspectRatio>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add aspect-ratio
Yew
use yew::prelude::*;
use crate::components::ui::aspect_ratio::AspectRatio;
#[component]
fn Usage() -> impl IntoView {
view! {
<div class="w-[450px]">
<AspectRatio ratio={16.0 / 9.0}>
<img src="..." alt="Image" class="rounded-md object-cover" />
</AspectRatio>
</div>
}
}
An image element with a fallback for representing the user.
Yew
Default
New York
avatar.rs
use yew::prelude::*;
use crate::components::ui::avatar::{Avatar, AvatarFallback, AvatarImage};
#[function_component]
pub fn AvatarDemo() -> Html {
html! {
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>{"CN"}</AvatarFallback>
</Avatar>
}
}
avatar.rs
use yew::prelude::*;
use crate::components::ui::avatar::{Avatar, AvatarFallback, AvatarImage};
#[function_component]
pub fn AvatarDemo() -> Html {
html! {
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>{"CN"}</AvatarFallback>
</Avatar>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add avatar
Yew
use yew::prelude::*;
use crate::components::ui::avatar::{Avatar, AvatarFallback, AvatarImage};
#[component]
fn Usage() -> impl IntoView {
view! {
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" />
<AvatarFallback>{"CN"}</AvatarFallback>
</Avatar>
}
}
Displays a badge or a component that looks like a badge.
Yew
Default
New York
badge.rs
use yew::prelude::*;
use crate::components::ui::badge::Badge;
#[function_component]
pub fn BadgeDemo() -> Html {
html! {
<Badge>{"Badge"}</Badge>
}
}
badge.rs
use yew::prelude::*;
use crate::components::ui::badge::Badge;
#[function_component]
pub fn BadgeDemo() -> Html {
html! {
<Badge>{"Badge"}</Badge>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
use yew::prelude::*;
use crate::components::ui::badge::{Badge, BadgeVariant};
#[component]
fn Usage() -> impl IntoView {
view! {
<Badge variant={BadgeVariant::Outline}>{"Badge"}>/Badge>
}
}
You can use the BadgeVariant
helper to create a link that looks like a badge.
Yew
use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::ui::badge::{Badge, BadgeClass, BadgeVariant};
#[component]
fn Usage() -> impl IntoView {
view! {
<Link class={BadgeClass::builder().variant(BadgeVariant::Outline).build().to_class()}>
{"Badge"}
</Link>
}
}
Yew
Default
New York
badge.rs
use yew::prelude::*;
use crate::components::ui::badge::Badge;
#[function_component]
pub fn BadgeDemo() -> Html {
html! {
<Badge>{"Badge"}</Badge>
}
}
badge.rs
use yew::prelude::*;
use crate::components::ui::badge::Badge;
#[function_component]
pub fn BadgeDemo() -> Html {
html! {
<Badge>{"Badge"}</Badge>
}
}
Yew
Default
New York
badge_secondary.rs
use yew::prelude::*;
use crate::default::components::ui::badge::{Badge, BadgeVariant};
#[function_component]
pub fn BadgeSecondary() -> Html {
html! {
<Badge variant={BadgeVariant::Secondary}>{"Secondary"}</Badge>
}
}
badge_secondary.rs
use yew::prelude::*;
use crate::new_york::components::ui::badge::{Badge, BadgeVariant};
#[function_component]
pub fn BadgeSecondary() -> Html {
html! {
<Badge variant={BadgeVariant::Secondary}>{"Secondary"}</Badge>
}
}
Yew
Default
New York
badge_outline.rs
use yew::prelude::*;
use crate::default::components::ui::badge::{Badge, BadgeVariant};
#[function_component]
pub fn BadgeOutline() -> Html {
html! {
<Badge variant={BadgeVariant::Outline}>{"Outline"}</Badge>
}
}
badge_outline.rs
use yew::prelude::*;
use crate::new_york::components::ui::badge::{Badge, BadgeVariant};
#[function_component]
pub fn BadgeOutline() -> Html {
html! {
<Badge variant={BadgeVariant::Outline}>{"Outline"}</Badge>
}
}
Yew
Default
New York
badge_destructive.rs
use yew::prelude::*;
use crate::default::components::ui::badge::{Badge, BadgeVariant};
#[function_component]
pub fn BadgeDestructive() -> Html {
html! {
<Badge variant={BadgeVariant::Destructive}>{"Destructive"}</Badge>
}
}
badge_destructive.rs
use yew::prelude::*;
use crate::new_york::components::ui::badge::{Badge, BadgeVariant};
#[function_component]
pub fn BadgeDestructive() -> Html {
html! {
<Badge variant={BadgeVariant::Destructive}>{"Destructive"}</Badge>
}
}
Displays the path to the current resource using a hierarchy of links.
Yew
Default
New York
breadcrumb.rs
use yew::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage,
BreadcrumbSeparator,
};
#[function_component]
pub fn BreadcrumbDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="#/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
// TODO
// <DropdownMenu>
// <DropdownMenuTrigger class="flex items-center gap-1">
// <BreadcrumbEllipsis class="h-4 w-4" />
// <span class="sr-only">{"Toggle menu"}</span>
// </DropdownMenuTrigger>
// <DropdownMenuContent align="start">
// <DropdownMenuItem>{"Documentation"}</DropdownMenuItem>
// <DropdownMenuItem>{"Themes"}</DropdownMenuItem>
// <DropdownMenuItem>{"GitHub"}</DropdownMenuItem>
// </DropdownMenuContent>
// </DropdownMenu>
<BreadcrumbEllipsis class="h-4 w-4" />
<span class="sr-only">{"Toggle menu"}</span>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="#/docs/components">{"Components"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
breadcrumb.rs
use yew::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage,
BreadcrumbSeparator,
};
#[function_component]
pub fn BreadcrumbDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="#/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
// TODO
// <DropdownMenu>
// <DropdownMenuTrigger class="flex items-center gap-1">
// <BreadcrumbEllipsis class="h-4 w-4" />
// <span class="sr-only">{"Toggle menu"}</span>
// </DropdownMenuTrigger>
// <DropdownMenuContent align="start">
// <DropdownMenuItem>{"Documentation"}</DropdownMenuItem>
// <DropdownMenuItem>{"Themes"}</DropdownMenuItem>
// <DropdownMenuItem>{"GitHub"}</DropdownMenuItem>
// </DropdownMenuContent>
// </DropdownMenu>
<BreadcrumbEllipsis class="h-4 w-4" />
<span class="sr-only">{"Toggle menu"}</span>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="#/docs/components">{"Components"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add breadcrumb
Yew
use yew::prelude::*;
use crate::components::ui::badge::{Badge, BadgeVariant};
#[component]
fn Usage() -> impl IntoView {
view! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="/components">{"Components"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
Use a custom component as children for <BreadcrumbSeparator />
to create a custom separator.
Yew
Default
New York
breadcrumb_separator.rs
use lucide_yew::Slash;
use yew::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator,
};
#[function_component]
pub fn BreadcrumbSeparatorDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="#/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbLink href="#/components">{"Components"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
breadcrumb_separator.rs
use radix_yew_icons::SlashIcon;
use yew::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator,
};
#[function_component]
pub fn BreadcrumbSeparatorDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="#/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<SlashIcon />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbLink href="#/components">{"Components"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<SlashIcon />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
You can compose <BreadcrumbItem />
with a <DropdownMenu />
to create a dropdown in the breadcrumb.
Yew
Default
New York
breadcrumb_dropdown.rs
use lucide_yew::{ChevronDown, Slash};
use yew::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator,
};
#[function_component]
pub fn BreadcrumbDropdown() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash />
</BreadcrumbSeparator>
<BreadcrumbItem>
// TODO
// <DropdownMenu>
// <DropdownMenuTrigger class="flex items-center gap-1">
// {"Components"}
// <ChevronDown class="h-4 w-4" />
// </DropdownMenuTrigger>
// <DropdownMenuContent align="start">
// <DropdownMenuItem>{"Documentation"}</DropdownMenuItem>
// <DropdownMenuItem>{"Themes"}</DropdownMenuItem>
// <DropdownMenuItem>{"GitHub"}</DropdownMenuItem>
// </DropdownMenuContent>
// </DropdownMenu>
{"Components"}
<ChevronDown class="h-4 w-4" />
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
breadcrumb_dropdown.rs
use radix_yew_icons::{ChevronDownIcon, SlashIcon};
use yew::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator,
};
#[function_component]
pub fn BreadcrumbDropdown() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">{"Home"}</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<SlashIcon />
</BreadcrumbSeparator>
<BreadcrumbItem>
// TODO
// <DropdownMenu>
// <DropdownMenuTrigger class="flex items-center gap-1">
// {"Components"}
// <ChevronDown class="h-4 w-4" />
// </DropdownMenuTrigger>
// <DropdownMenuContent align="start">
// <DropdownMenuItem>{"Documentation"}</DropdownMenuItem>
// <DropdownMenuItem>{"Themes"}</DropdownMenuItem>
// <DropdownMenuItem>{"GitHub"}</DropdownMenuItem>
// </DropdownMenuContent>
// </DropdownMenu>
{"Components"}
<ChevronDownIcon class="h-4 w-4" />
</BreadcrumbItem>
<BreadcrumbSeparator>
<SlashIcon />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
A <BreadcrumbEllipsis />
component is provided to show a collapsed state when the breadcrumb is too long.
Yew
Default
New York
breadcrumb_ellipsis.rs
use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbLinkChildProps,
BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator,
};
#[derive(Clone, PartialEq, Routable)]
enum Route {
#[at("/")]
Home,
#[at("/docs/components")]
Components,
}
#[function_component]
pub fn BreadcrumbEllipsisDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Home"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbEllipsis />
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Components"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
breadcrumb_ellipsis.rs
use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbLinkChildProps,
BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator,
};
#[derive(Clone, PartialEq, Routable)]
enum Route {
#[at("/")]
Home,
#[at("/docs/components")]
Components,
}
#[function_component]
pub fn BreadcrumbEllipsisDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Home"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbEllipsis />
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Components"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
To use a custom link component from your routing library, you can use the as_child
prop on <BreadcrumbLink />
.
Yew
Default
New York
breadcrumb_link.rs
use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbLinkChildProps, BreadcrumbList,
BreadcrumbPage, BreadcrumbSeparator,
};
#[derive(Clone, PartialEq, Routable)]
enum Route {
#[at("/")]
Home,
#[at("/components")]
Components,
}
#[function_component]
pub fn BreadcrumbLinkDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Home"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Components"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
breadcrumb_link.rs
use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::ui::breadcrumb::{
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbLinkChildProps, BreadcrumbList,
BreadcrumbPage, BreadcrumbSeparator,
};
#[derive(Clone, PartialEq, Routable)]
enum Route {
#[at("/")]
Home,
#[at("/components")]
Components,
}
#[function_component]
pub fn BreadcrumbLinkDemo() -> Html {
html! {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Home"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink
as_child={Callback::from(|BreadcrumbLinkChildProps {class, ..}| html! {
<Link<Route> classes={classes!(class)} to={Route::Home}>{"Components"}</Link<Route>>
})}
/>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
}
Here's an example of a responsive breadcrumb that composes <BreadcrumbItem />
with <BreadcrumbEllipsis />
, <DropdownMenu />
, and <Drawer />
.
It displays a dropdown on desktop and a drawer on mobile.
Yew
Default
New York
breadcrumb_responsive.rs
use yew::prelude::*;
// use crate::components::ui::breadcrumb::{
// Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage,
// BreadcrumbSeparator,
// };
#[function_component]
pub fn BreadcrumbResponsive() -> Html {
html! {
// TODO
}
}
breadcrumb_responsive.rs
use yew::prelude::*;
// use crate::default::components::ui::breadcrumb::{
// Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage,
// BreadcrumbSeparator,
// };
#[function_component]
pub fn BreadcrumbResponsive() -> Html {
html! {
// TODO
}
}
Displays a button or a component that looks like a button.
Yew
Default
New York
button.rs
use yew::prelude::*;
use crate::components::ui::button::Button;
#[function_component]
pub fn ButtonDemo() -> Html {
html! {
<Button>{"Button"}</Button>
}
}
button.rs
use yew::prelude::*;
use crate::components::ui::button::Button;
#[function_component]
pub fn ButtonDemo() -> Html {
html! {
<Button>{"Button"}</Button>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add button
Yew
use yew::prelude::*;
use crate::components::ui::button::{Button, ButtonVariant};
#[component]
fn Usage() -> impl IntoView {
view! {
<Button variant={ButtonVariant::Outline}>{"Button"}>/Button>
}
}
Yew
Default
New York
button.rs
use yew::prelude::*;
use crate::components::ui::button::Button;
#[function_component]
pub fn ButtonDemo() -> Html {
html! {
<Button>{"Button"}</Button>
}
}
button.rs
use yew::prelude::*;
use crate::components::ui::button::Button;
#[function_component]
pub fn ButtonDemo() -> Html {
html! {
<Button>{"Button"}</Button>
}
}
Yew
Default
New York
button_secondary.rs
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonSecondary() -> Html {
html! {
<Button variant={ButtonVariant::Secondary}>{"Secondary"}</Button>
}
}
button_secondary.rs
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonSecondary() -> Html {
html! {
<Button variant={ButtonVariant::Secondary}>{"Secondary"}</Button>
}
}
Yew
Default
New York
button_destructive.rs
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonDestructive() -> Html {
html! {
<Button variant={ButtonVariant::Destructive}>{"Destructive"}</Button>
}
}
button_destructive.rs
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonDestructive() -> Html {
html! {
<Button variant={ButtonVariant::Destructive}>{"Destructive"}</Button>
}
}
Yew
Default
New York
button_outline.rs
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonOutline() -> Html {
html! {
<Button variant={ButtonVariant::Outline}>{"Outline"}</Button>
}
}
button_outline.rs
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonOutline() -> Html {
html! {
<Button variant={ButtonVariant::Outline}>{"Outline"}</Button>
}
}
Yew
Default
New York
button_ghost.rs
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonGhost() -> Html {
html! {
<Button variant={ButtonVariant::Ghost}>{"Ghost"}</Button>
}
}
button_ghost.rs
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonGhost() -> Html {
html! {
<Button variant={ButtonVariant::Ghost}>{"Ghost"}</Button>
}
}
Yew
Default
New York
button_link.rs
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonLink() -> Html {
html! {
<Button variant={ButtonVariant::Link}>{"Link"}</Button>
}
}
button_link.rs
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonVariant};
#[function_component]
pub fn ButtonLink() -> Html {
html! {
<Button variant={ButtonVariant::Link}>{"Link"}</Button>
}
}
Yew
Default
New York
button_icon.rs
use lucide_yew::ChevronRight;
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonSize, ButtonVariant};
#[function_component]
pub fn ButtonIcon() -> Html {
html! {
<Button variant={ButtonVariant::Outline} size={ButtonSize::Icon}>
<ChevronRight class="h-4 w-4" />
</Button>
}
}
button_icon.rs
use radix_yew_icons::ChevronRightIcon;
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonSize, ButtonVariant};
#[function_component]
pub fn ButtonIcon() -> Html {
html! {
<Button variant={ButtonVariant::Outline} size={ButtonSize::Icon}>
<ChevronRightIcon class="h-4 w-4" />
</Button>
}
}
Yew
Default
New York
button_with_icon.rs
use lucide_yew::Mail;
use yew::prelude::*;
use crate::default::components::ui::button::Button;
#[function_component]
pub fn ButtonWithIcon() -> Html {
html! {
<Button>
<Mail class="mr-2 h-4 w-4" />
{"Login with Email"}
</Button>
}
}
button_with_icon.rs
use radix_yew_icons::EnvelopeOpenIcon;
use yew::prelude::*;
use crate::new_york::components::ui::button::Button;
#[function_component]
pub fn ButtonWithIcon() -> Html {
html! {
<Button>
<EnvelopeOpenIcon />
{"Login with Email"}
</Button>
}
}
Yew
Default
New York
button_loading.rs
use lucide_yew::LoaderCircle;
use yew::prelude::*;
use crate::default::components::ui::button::Button;
#[function_component]
pub fn ButtonLoading() -> Html {
html! {
<Button disabled=true>
<LoaderCircle class="mr-2 h-4 w-4 animate-spin" />
{"Please wait"}
</Button>
}
}
button_loading.rs
use radix_yew_icons::ReloadIcon;
use yew::prelude::*;
use crate::new_york::components::ui::button::Button;
#[function_component]
pub fn ButtonLoading() -> Html {
html! {
<Button disabled=true>
<ReloadIcon class="mr-2 h-4 w-4 animate-spin" />
{"Please wait"}
</Button>
}
}
Yew
Default
New York
button_as_child.rs
use yew::prelude::*;
use crate::default::components::ui::button::{Button, ButtonChildProps};
#[function_component]
pub fn ButtonAsChild() -> Html {
html! {
<Button
as_child={Callback::from(|ButtonChildProps {class, ..}| html! {
<a class={class} href="#/login">{"Login"}</a>
})}
/>
}
}
button_as_child.rs
use yew::prelude::*;
use crate::new_york::components::ui::button::{Button, ButtonChildProps};
#[function_component]
pub fn ButtonAsChild() -> Html {
html! {
<Button
as_child={Callback::from(|ButtonChildProps {class, ..}| html! {
<a class={class} href="#/login">{"Login"}</a>
})}
/>
}
}
Displays a card with header, content, and footer.
Yew
Default
New York
card_with_form.rs
use yew::prelude::*;
use crate::components::ui::{
button::{Button, ButtonVariant},
card::{Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle},
input::Input,
label::Label,
};
#[function_component]
pub fn CardWithForm() -> Html {
html! {
<Card class="w-[350px]">
<CardHeader>
<CardTitle>{"Create project"}</CardTitle>
<CardDescription>{"Deploy your new project in one-click."}</CardDescription>
</CardHeader>
<CardContent>
<form>
<div class="grid w-full items-center gap-4">
<div class="flex flex-col space-y-1.5">
<Label r#for="name">{"Name"}</Label>
<Input id="name" placeholder="Name of your project" />
</div>
<div class="flex flex-col space-y-1.5">
<Label r#for="framework">{"Framework"}</Label>
// TODO
// <Select>
// <SelectTrigger id="framework">
// <SelectValue placeholder="Select" />
// </SelectTrigger>
// <SelectContent position="popper">
// <SelectItem value="next">{"Next.js"}</SelectItem>
// <SelectItem value="sveltekit">{"SvelteKit"}</SelectItem>
// <SelectItem value="astro">{"Astro"}</SelectItem>
// <SelectItem value="nuxt">{"Nuxt.js"}</SelectItem>
// </SelectContent>
// </Select>
</div>
</div>
</form>
</CardContent>
<CardFooter class="flex justify-between">
<Button variant={ButtonVariant::Outline}>{"Cancel"}</Button>
<Button>{"Deploy"}</Button>
</CardFooter>
</Card>
}
}
card_with_form.rs
use yew::prelude::*;
use crate::components::ui::{
button::{Button, ButtonVariant},
card::{Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle},
input::Input,
label::Label,
};
#[function_component]
pub fn CardWithForm() -> Html {
html! {
<Card class="w-[350px]">
<CardHeader>
<CardTitle>{"Create project"}</CardTitle>
<CardDescription>{"Deploy your new project in one-click."}</CardDescription>
</CardHeader>
<CardContent>
<form>
<div class="grid w-full items-center gap-4">
<div class="flex flex-col space-y-1.5">
<Label r#for="name">{"Name"}</Label>
<Input id="name" placeholder="Name of your project" />
</div>
<div class="flex flex-col space-y-1.5">
<Label r#for="framework">{"Framework"}</Label>
// TODO
// <Select>
// <SelectTrigger id="framework">
// <SelectValue placeholder="Select" />
// </SelectTrigger>
// <SelectContent position="popper">
// <SelectItem value="next">{"Next.js"}</SelectItem>
// <SelectItem value="sveltekit">{"SvelteKit"}</SelectItem>
// <SelectItem value="astro">{"Astro"}</SelectItem>
// <SelectItem value="nuxt">{"Nuxt.js"}</SelectItem>
// </SelectContent>
// </Select>
</div>
</div>
</form>
</CardContent>
<CardFooter class="flex justify-between">
<Button variant={ButtonVariant::Outline}>{"Cancel"}</Button>
<Button>{"Deploy"}</Button>
</CardFooter>
</Card>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
use yew::prelude::*;
use crate::components::ui::card::{
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
};
#[component]
fn Usage() -> impl IntoView {
view! {
<Card>
<CardHeader>
<CardTitle>{"Card Title"}</CardTitle>
<CardDescription>{"Card Description"}</CardDescription>
</CardHeader>
<CardContent>
<p>{"Card Content"}</p>
</CardContent>
<CardFooter>
<p>{"Card Footer"}</p>
</CardFooter>
</Card>
}
}
Yew
Default
New York
card.rs
use lucide_yew::{BellRing, Check};
use yew::prelude::*;
use crate::components::ui::{
button::Button,
card::{Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle},
switch::Switch,
};
struct Notification {
title: &'static str,
description: &'static str,
}
fn notifications() -> Vec<Notification> {
vec![
Notification {
title: "Your call has been confirmed.",
description: "1 hour ago",
},
Notification {
title: "You have a new message!",
description: "1 hour ago",
},
Notification {
title: "Your subscription is expiring soon!",
description: "2 hours ago",
},
]
}
#[function_component]
pub fn CardDemo() -> Html {
html! {
<Card class="w-[380px]">
<CardHeader>
<CardTitle>{"Notifications"}</CardTitle>
<CardDescription>{"You have 3 unread messages."}</CardDescription>
</CardHeader>
<CardContent class="grid gap-4">
<div class=" flex items-center space-x-4 rounded-md border p-4">
<BellRing />
<div class="flex-1 space-y-1">
<p class="text-sm font-medium leading-none">
{"Push Notifications"}
</p>
<p class="text-sm text-muted-foreground">
{"Send notifications to device."}
</p>
</div>
<Switch />
</div>
<div>
{notifications().iter().enumerate().map(|(index, notification)| html! {
<div
key={index}
class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0"
>
<span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500" />
<div class="space-y-1">
<p class="text-sm font-medium leading-none">
{notification.title}
</p>
<p class="text-sm text-muted-foreground">
{notification.description}
</p>
</div>
</div>
}).collect::<Html>()}
</div>
</CardContent>
<CardFooter>
<Button class="w-full">
<Check />{" Mark all as read"}
</Button>
</CardFooter>
</Card>
}
}
card.rs
use radix_yew_icons::{BellIcon, CheckIcon};
use yew::prelude::*;
use crate::components::ui::{
button::Button,
card::{Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle},
switch::Switch,
};
struct Notification {
title: &'static str,
description: &'static str,
}
fn notifications() -> Vec<Notification> {
vec![
Notification {
title: "Your call has been confirmed.",
description: "1 hour ago",
},
Notification {
title: "You have a new message!",
description: "1 hour ago",
},
Notification {
title: "Your subscription is expiring soon!",
description: "2 hours ago",
},
]
}
#[function_component]
pub fn CardDemo() -> Html {
html! {
<Card class="w-[380px]">
<CardHeader>
<CardTitle>{"Notifications"}</CardTitle>
<CardDescription>{"You have 3 unread messages."}</CardDescription>
</CardHeader>
<CardContent class="grid gap-4">
<div class=" flex items-center space-x-4 rounded-md border p-4">
<BellIcon />
<div class="flex-1 space-y-1">
<p class="text-sm font-medium leading-none">
{"Push Notifications"}
</p>
<p class="text-sm text-muted-foreground">
{"Send notifications to device."}
</p>
</div>
<Switch />
</div>
<div>
{notifications().iter().enumerate().map(|(index, notification)| html! {
<div
key={index}
class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0"
>
<span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500" />
<div class="space-y-1">
<p class="text-sm font-medium leading-none">
{notification.title}
</p>
<p class="text-sm text-muted-foreground">
{notification.description}
</p>
</div>
</div>
}).collect::<Html>()}
</div>
</CardContent>
<CardFooter>
<Button class="w-full">
<CheckIcon />{" Mark all as read"}
</Button>
</CardFooter>
</Card>
}
}
Displays a form input field or a component that looks like an input field.
Yew
Default
New York
input.rs
use yew::prelude::*;
use crate::components::ui::input::Input;
#[function_component]
pub fn InputDemo() -> Html {
html! {
<Input r#type="email" placeholder="Email" />
}
}
input.rs
use yew::prelude::*;
use crate::components::ui::input::Input;
#[function_component]
pub fn InputDemo() -> Html {
html! {
<Input r#type="email" placeholder="Email" />
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
use yew::prelude::*;
use crate::components::ui::input::Input;
#[component]
fn Usage() -> impl IntoView {
view! {
<Input />
}
}
Yew
Default
New York
input.rs
use yew::prelude::*;
use crate::components::ui::input::Input;
#[function_component]
pub fn InputDemo() -> Html {
html! {
<Input r#type="email" placeholder="Email" />
}
}
input.rs
use yew::prelude::*;
use crate::components::ui::input::Input;
#[function_component]
pub fn InputDemo() -> Html {
html! {
<Input r#type="email" placeholder="Email" />
}
}
Yew
Default
New York
input_file.rs
use yew::prelude::*;
use crate::components::ui::{input::Input, label::Label};
#[function_component]
pub fn InputFile() -> Html {
html! {
<div class="grid w-full max-w-sm items-center gap-1.5">
<Label r#for="picture">{"Picture"}</Label>
<Input id="picture" r#type="file" />
</div>
}
}
input_file.rs
use yew::prelude::*;
use crate::components::ui::{input::Input, label::Label};
#[function_component]
pub fn InputFile() -> Html {
html! {
<div class="grid w-full max-w-sm items-center gap-1.5">
<Label r#for="picture">{"Picture"}</Label>
<Input id="picture" r#type="file" />
</div>
}
}
Yew
Default
New York
input_disabled.rs
use yew::prelude::*;
use crate::components::ui::input::Input;
#[function_component]
pub fn InputDisabled() -> Html {
html! {
<Input disabled=true r#type="email" placeholder="Email" />
}
}
input_disabled.rs
use yew::prelude::*;
use crate::components::ui::input::Input;
#[function_component]
pub fn InputDisabled() -> Html {
html! {
<Input disabled=true r#type="email" placeholder="Email" />
}
}
Yew
Default
New York
input_with_label.rs
use yew::prelude::*;
use crate::components::ui::{input::Input, label::Label};
#[function_component]
pub fn InputWithLabel() -> Html {
html! {
<div class="grid w-full max-w-sm items-center gap-1.5">
<Label r#for="email">{"Email"}</Label>
<Input r#type="email" id="email" placeholder="Email" />
</div>
}
}
input_with_label.rs
use yew::prelude::*;
use crate::components::ui::{input::Input, label::Label};
#[function_component]
pub fn InputWithLabel() -> Html {
html! {
<div class="grid w-full max-w-sm items-center gap-1.5">
<Label r#for="email">{"Email"}</Label>
<Input r#type="email" id="email" placeholder="Email" />
</div>
}
}
Yew
Default
New York
input_with_text.rs
use yew::prelude::*;
use crate::components::ui::{input::Input, label::Label};
#[function_component]
pub fn InputWithText() -> Html {
html! {
<div class="grid w-full max-w-sm items-center gap-1.5">
<Label r#for="email-2">{"Email"}</Label>
<Input r#type="email" id="email-2" placeholder="Email" />
<p class="text-sm text-muted-foreground">{"Enter your email address."}</p>
</div>
}
}
input_with_text.rs
use yew::prelude::*;
use crate::components::ui::{input::Input, label::Label};
#[function_component]
pub fn InputWithText() -> Html {
html! {
<div class="grid w-full max-w-sm items-center gap-1.5">
<Label r#for="email-2">{"Email"}</Label>
<Input r#type="email" id="email-2" placeholder="Email" />
<p class="text-sm text-muted-foreground">{"Enter your email address."}</p>
</div>
}
}
Yew
Default
New York
input_with_button.rs
use yew::prelude::*;
use crate::components::ui::{button::Button, input::Input};
#[function_component]
pub fn InputWithButton() -> Html {
html! {
<div class="flex w-full max-w-sm items-center space-x-2">
<Input r#type="email" placeholder="Email" />
<Button r#type="submit">{"Subscribe"}</Button>
</div>
}
}
input_with_button.rs
use yew::prelude::*;
use crate::components::ui::{button::Button, input::Input};
#[function_component]
pub fn InputWithButton() -> Html {
html! {
<div class="flex w-full max-w-sm items-center space-x-2">
<Input r#type="email" placeholder="Email" />
<Button r#type="submit">{"Subscribe"}</Button>
</div>
}
}
Yew
Default
New York
input_form.rs
use yew::prelude::*;
// use crate::components::ui::input::Input;
#[function_component]
pub fn InputForm() -> Html {
html! {
// TODO
}
}
input_form.rs
use yew::prelude::*;
// use crate::components::ui::input::Input;
#[function_component]
pub fn InputForm() -> Html {
html! {
// TODO
}
}
Renders an accessible label associated with controls.
Yew
Default
New York
label.rs
use yew::prelude::*;
use crate::components::ui::label::Label;
#[function_component]
pub fn LabelDemo() -> Html {
html! {
<div>
<div class="flex items-center space-x-2">
// TODO
// <Checkbox id="terms" />
<Label r#for="terms">{"Accept terms and conditions"}</Label>
</div>
</div>
}
}
label.rs
use yew::prelude::*;
use crate::components::ui::label::Label;
#[function_component]
pub fn LabelDemo() -> Html {
html! {
<div>
<div class="flex items-center space-x-2">
// TODO
// <Checkbox id="terms" />
<Label r#for="terms">{"Accept terms and conditions"}</Label>
</div>
</div>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
use yew::prelude::*;
use crate::components::ui::label::Label;
#[component]
fn Usage() -> impl IntoView {
view! {
<Label r#for="email">{"Your email address"}</Label>
}
}
Pagination with page navigation, next and previous links.
Yew
Default
New York
pagination.rs
use yew::prelude::*;
use crate::components::ui::pagination::{
Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink,
PaginationNext, PaginationPrevious,
};
#[function_component]
pub fn PaginationDemo() -> Html {
html! {
<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="#" />
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">{"1"}</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="#" is_active=true>
{"2"}
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">{"3"}</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
<PaginationItem>
<PaginationNext href="#" />
</PaginationItem>
</PaginationContent>
</Pagination>
}
}
pagination.rs
use yew::prelude::*;
use crate::components::ui::pagination::{
Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink,
PaginationNext, PaginationPrevious,
};
#[function_component]
pub fn PaginationDemo() -> Html {
html! {
<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="#" />
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">{"1"}</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="#" is_active=true>
{"2"}
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">{"3"}</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
<PaginationItem>
<PaginationNext href="#" />
</PaginationItem>
</PaginationContent>
</Pagination>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add pagination
Yew
use yew::prelude::*;
use crate::components::ui::pagination::{
Pagination,
PaginationContent,
PaginationEllipsis,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
};
#[component]
fn Usage() -> impl IntoView {
view! {
<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="#" />
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">{"1"}</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
<PaginationItem>
<PaginationNext href="#" />
</PaginationItem>
</PaginationContent>
</Pagination>
}
}
By default the <PaginationLink />
component will render an <a />
tag.
To use a router link component, make the following updates to pagination.rs
:
Yew
+ use yew_router::prelude::*;
html! {
- <a>
+ <Link>
// ...
- </a>
+ </Link>
}
Visually or semantically separates content.
Yew
Default
New York
separator.rs
use yew::prelude::*;
use crate::components::ui::separator::{Orientation, Separator};
#[function_component]
pub fn SeparatorDemo() -> Html {
html! {
<div>
<div class="space-y-1">
<h4 class="text-sm font-medium leading-none">{"Radix Primitives"}</h4>
<p class="text-sm text-muted-foreground">
{"An open-source UI component library."}
</p>
</div>
<Separator class="my-4" />
<div class="flex h-5 items-center space-x-4 text-sm">
<div>{"Blog"}</div>
<Separator orientation={Orientation::Vertical} />
<div>{"Docs"}</div>
<Separator orientation={Orientation::Vertical} />
<div>{"Source"}</div>
</div>
</div>
}
}
separator.rs
use yew::prelude::*;
use crate::components::ui::separator::{Orientation, Separator};
#[function_component]
pub fn SeparatorDemo() -> Html {
html! {
<div>
<div class="space-y-1">
<h4 class="text-sm font-medium leading-none">{"Radix Primitives"}</h4>
<p class="text-sm text-muted-foreground">
{"An open-source UI component library."}
</p>
</div>
<Separator class="my-4" />
<div class="flex h-5 items-center space-x-4 text-sm">
<div>{"Blog"}</div>
<Separator orientation={Orientation::Vertical} />
<div>{"Docs"}</div>
<Separator orientation={Orientation::Vertical} />
<div>{"Source"}</div>
</div>
</div>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add separator
Yew
use yew::prelude::*;
use crate::components::ui::separator::Separator;
#[component]
fn Usage() -> impl IntoView {
view! {
<Separator />
}
}
Use to show a placeholder while content is loading.
Yew
Default
New York
skeleton.rs
use yew::prelude::*;
use crate::components::ui::skeleton::Skeleton;
#[function_component]
pub fn SkeletonDemo() -> Html {
html! {
<div class="flex items-center space-x-4">
<Skeleton class="h-12 w-12 rounded-full" />
<div class="space-y-2">
<Skeleton class="h-4 w-[250px]" />
<Skeleton class="h-4 w-[200px]" />
</div>
</div>
}
}
skeleton.rs
use yew::prelude::*;
use crate::components::ui::skeleton::Skeleton;
#[function_component]
pub fn SkeletonDemo() -> Html {
html! {
<div class="flex items-center space-x-4">
<Skeleton class="h-12 w-12 rounded-full" />
<div class="space-y-2">
<Skeleton class="h-4 w-[250px]" />
<Skeleton class="h-4 w-[200px]" />
</div>
</div>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add skeleton
Yew
use yew::prelude::*;
use crate::components::ui::skeleton::{Skeleton};
#[component]
fn Usage() -> impl IntoView {
view! {
<Skeleton class="w-[100px] h-[20px] rounded-full" />
}
}
Yew
Default
New York
skeleton_card.rs
use yew::prelude::*;
use crate::components::ui::skeleton::Skeleton;
#[function_component]
pub fn SkeletonCard() -> Html {
html! {
<div class="flex flex-col space-y-3">
<Skeleton class="h-[125px] w-[250px] rounded-xl" />
<div class="space-y-2">
<Skeleton class="h-4 w-[250px]" />
<Skeleton class="h-4 w-[200px]" />
</div>
</div>
}
}
skeleton_card.rs
use yew::prelude::*;
use crate::components::ui::skeleton::Skeleton;
#[function_component]
pub fn SkeletonCard() -> Html {
html! {
<div class="flex flex-col space-y-3">
<Skeleton class="h-[125px] w-[250px] rounded-xl" />
<div class="space-y-2">
<Skeleton class="h-4 w-[250px]" />
<Skeleton class="h-4 w-[200px]" />
</div>
</div>
}
}
A control that allows the user to toggle between checked and not checked.
Yew
Default
New York
switch.rs
use yew::prelude::*;
use crate::components::ui::{label::Label, switch::Switch};
#[function_component]
pub fn SwitchDemo() -> Html {
html! {
<div class="flex items-center space-x-2">
<Switch id="airplane-mode" />
<Label r#for="airplane-mode">{"Airplane Mode"}</Label>
</div>
}
}
switch.rs
use yew::prelude::*;
use crate::components::ui::{label::Label, switch::Switch};
#[function_component]
pub fn SwitchDemo() -> Html {
html! {
<div class="flex items-center space-x-2">
<Switch id="airplane-mode" />
<Label r#for="airplane-mode">{"Airplane Mode"}</Label>
</div>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add switch
Yew
use yew::prelude::*;
use crate::components::ui::switch::Switch;
#[component]
fn Usage() -> impl IntoView {
view! {
<Switch />
}
}
Yew
Default
New York
switch_form.rs
use yew::prelude::*;
// use crate::components::ui::switch::Switch;
#[function_component]
pub fn SwitchForm() -> Html {
html! {
// TODO
}
}
switch_form.rs
use yew::prelude::*;
// use crate::default::components::ui::switch::Switch;
#[function_component]
pub fn SwitchForm() -> Html {
html! {
// TODO
}
}
A responsive table component.
Yew
Default
New York
table.rs
use yew::prelude::*;
use crate::components::ui::table::{
Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow,
};
struct Invoice {
invoice: &'static str,
payment_status: &'static str,
total_amount: &'static str,
payment_method: &'static str,
}
fn invoices() -> Vec<Invoice> {
vec![
Invoice {
invoice: "INV001",
payment_status: "Paid",
total_amount: "$250.00",
payment_method: "Credit Card",
},
Invoice {
invoice: "INV002",
payment_status: "Pending",
total_amount: "$150.00",
payment_method: "PayPal",
},
Invoice {
invoice: "INV003",
payment_status: "Unpaid",
total_amount: "$350.00",
payment_method: "Bank Transfer",
},
Invoice {
invoice: "INV004",
payment_status: "Paid",
total_amount: "$450.00",
payment_method: "Credit Card",
},
Invoice {
invoice: "INV005",
payment_status: "Paid",
total_amount: "$550.00",
payment_method: "PayPal",
},
Invoice {
invoice: "INV006",
payment_status: "Pending",
total_amount: "$200.00",
payment_method: "Bank Transfer",
},
Invoice {
invoice: "INV007",
payment_status: "Unpaid",
total_amount: "$300.00",
payment_method: "Credit Card",
},
]
}
#[function_component]
pub fn TableDemo() -> Html {
html! {
<Table>
<TableCaption>{"A list of your recent invoices."}</TableCaption>
<TableHeader>
<TableRow>
<TableHead class="w-[100px]">{"Invoice"}</TableHead>
<TableHead>{"Status"}</TableHead>
<TableHead>{"Method"}</TableHead>
<TableHead class="text-right">{"Amount"}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices().into_iter().map(|invoice| html! {
<TableRow key={invoice.invoice}>
<TableCell class="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.payment_status}</TableCell>
<TableCell>{invoice.payment_method}</TableCell>
<TableCell class="text-right">{invoice.total_amount}</TableCell>
</TableRow>
}).collect::<Html>()}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colspan="3">{"Total"}</TableCell>
<TableCell class="text-right">{"$2,500.00"}</TableCell>
</TableRow>
</TableFooter>
</Table>
}
}
table.rs
use yew::prelude::*;
use crate::components::ui::table::{
Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow,
};
struct Invoice {
invoice: &'static str,
payment_status: &'static str,
total_amount: &'static str,
payment_method: &'static str,
}
fn invoices() -> Vec<Invoice> {
vec![
Invoice {
invoice: "INV001",
payment_status: "Paid",
total_amount: "$250.00",
payment_method: "Credit Card",
},
Invoice {
invoice: "INV002",
payment_status: "Pending",
total_amount: "$150.00",
payment_method: "PayPal",
},
Invoice {
invoice: "INV003",
payment_status: "Unpaid",
total_amount: "$350.00",
payment_method: "Bank Transfer",
},
Invoice {
invoice: "INV004",
payment_status: "Paid",
total_amount: "$450.00",
payment_method: "Credit Card",
},
Invoice {
invoice: "INV005",
payment_status: "Paid",
total_amount: "$550.00",
payment_method: "PayPal",
},
Invoice {
invoice: "INV006",
payment_status: "Pending",
total_amount: "$200.00",
payment_method: "Bank Transfer",
},
Invoice {
invoice: "INV007",
payment_status: "Unpaid",
total_amount: "$300.00",
payment_method: "Credit Card",
},
]
}
#[function_component]
pub fn TableDemo() -> Html {
html! {
<Table>
<TableCaption>{"A list of your recent invoices."}</TableCaption>
<TableHeader>
<TableRow>
<TableHead class="w-[100px]">{"Invoice"}</TableHead>
<TableHead>{"Status"}</TableHead>
<TableHead>{"Method"}</TableHead>
<TableHead class="text-right">{"Amount"}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices().into_iter().map(|invoice| html! {
<TableRow key={invoice.invoice}>
<TableCell class="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.payment_status}</TableCell>
<TableCell>{invoice.payment_method}</TableCell>
<TableCell class="text-right">{invoice.total_amount}</TableCell>
</TableRow>
}).collect::<Html>()}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colspan="3">{"Total"}</TableCell>
<TableCell class="text-right">{"$2,500.00"}</TableCell>
</TableRow>
</TableFooter>
</Table>
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
use yew::prelude::*;
use crate::components::ui::table::{
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
TableRow,
};
#[component]
fn Usage() -> impl IntoView {
view! {
<Table>
<TableCaption>{"A list of your recent invoices."}</TableCaption>
<TableHeader>
<TableRow>
<TableHead class="w-[100px]">{"Invoice"}</TableHead>
<TableHead>{"Status"}</TableHead>
<TableHead>{"Method"}</TableHead>
<TableHead class="text-right">{"Amount"}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell class="font-medium">{"INV001"}</TableCell>
<TableCell>{"Paid"}</TableCell>
<TableCell>{"Credit Card"}</TableCell>
<TableCell class="text-right">{"$250.00"}</TableCell>
</TableRow>
</TableBody>
</Table>
}
}
Displays a form textarea or a component that looks like a textarea.
Yew
Default
New York
textarea.rs
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaDemo() -> Html {
html! {
<Textarea placeholder="Type your message here." />
}
}
textarea.rs
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaDemo() -> Html {
html! {
<Textarea placeholder="Type your message here." />
}
}
The CLI is not yet available. For now, manually copy the component source into your project.
Yew
rust-shadcn-ui add textarea
Yew
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[component]
fn Usage() -> impl IntoView {
view! {
<Textarea />
}
}
Yew
Default
New York
textarea.rs
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaDemo() -> Html {
html! {
<Textarea placeholder="Type your message here." />
}
}
textarea.rs
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaDemo() -> Html {
html! {
<Textarea placeholder="Type your message here." />
}
}
Yew
Default
New York
textarea_disabled.rs
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaDisabled() -> Html {
html! {
<Textarea placeholder="Type your message here." disabled=true />
}
}
textarea_disabled.rs
use yew::prelude::*;
use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaDisabled() -> Html {
html! {
<Textarea placeholder="Type your message here." disabled=true />
}
}
Yew
Default
New York
textarea_with_label.rs
use yew::prelude::*;
use crate::components::ui::{label::Label, textarea::Textarea};
#[function_component]
pub fn TextareaWithLabel() -> Html {
html! {
<div class="grid w-full gap-1.5">
<Label r#for="message">{"Your message"}</Label>
<Textarea placeholder="Type your message here." id="message" />
</div>
}
}
textarea_with_label.rs
use yew::prelude::*;
use crate::components::ui::{label::Label, textarea::Textarea};
#[function_component]
pub fn TextareaWithLabel() -> Html {
html! {
<div class="grid w-full gap-1.5">
<Label r#for="message">{"Your message"}</Label>
<Textarea placeholder="Type your message here." id="message" />
</div>
}
}
Yew
Default
New York
textarea_with_text.rs
use yew::prelude::*;
use crate::components::ui::{label::Label, textarea::Textarea};
#[function_component]
pub fn TextareaWithText() -> Html {
html! {
<div class="grid w-full gap-1.5">
<Label r#for="message-2">{"Your Message"}</Label>
<Textarea placeholder="Type your message here." id="message-2" />
<p class="text-sm text-muted-foreground">
{"Your message will be copied to the support team."}
</p>
</div>
}
}
textarea_with_text.rs
use yew::prelude::*;
use crate::components::ui::{label::Label, textarea::Textarea};
#[function_component]
pub fn TextareaWithText() -> Html {
html! {
<div class="grid w-full gap-1.5">
<Label r#for="message-2">{"Your Message"}</Label>
<Textarea placeholder="Type your message here." id="message-2" />
<p class="text-sm text-muted-foreground">
{"Your message will be copied to the support team."}
</p>
</div>
}
}
Yew
Default
New York
textarea_with_button.rs
use yew::prelude::*;
use crate::components::ui::{button::Button, textarea::Textarea};
#[function_component]
pub fn TextareaWithButton() -> Html {
html! {
<div class="grid w-full gap-2">
<Textarea placeholder="Type your message here." />
<Button>{"Send message"}</Button>
</div>
}
}
textarea_with_button.rs
use yew::prelude::*;
use crate::components::ui::{button::Button, textarea::Textarea};
#[function_component]
pub fn TextareaWithButton() -> Html {
html! {
<div class="grid w-full gap-2">
<Textarea placeholder="Type your message here." />
<Button>{"Send message"}</Button>
</div>
}
}
Yew
Default
New York
textarea_form.rs
use yew::prelude::*;
// use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaForm() -> Html {
html! {
// TODO
}
}
textarea_form.rs
use yew::prelude::*;
// use crate::components::ui::textarea::Textarea;
#[function_component]
pub fn TextareaForm() -> Html {
html! {
// TODO
}
}