Styling Native Widgets
Call .tw(...) on any native Iced widget after importing TwExt, and use ISS layout helpers (row_tw, col_tw, flex_tw, grid_tw) for multi-child containers.
Native Widget Cheat Sheet
Section titled “Native Widget Cheat Sheet”Every widget below accepts compile-time tw!("..."), typed IssStyle builders, or viewport-resolved vp.tw(...).
| Iced Widget | Common Classes | Notes |
|---|---|---|
container(...) |
p-*, w-*, h-*, bg-*, bg-linear-to-*, border, rounded-*, shadow-*, backdrop-blur-*, overflow-hidden |
Add overflow-hidden when flush children touch rounded-* corners |
button(...) |
px-*, py-*, bg-*, hover:*, active:*, disabled:*, border, rounded-*, cursor-pointer |
Hover/active overrides automatically inherit base rounded-*, border, and shadow-* |
text(...) |
text-sm, font-semibold, italic, leading-*, tracking-*, text-*, underline, truncate, line-clamp-* |
Wrap text inside button(text("Save").tw(...)) to style button label typography |
text_input(...) |
px-*, py-*, bg-*, border, focus:border-*, placeholder:*, caret-*, rounded-* |
Use .tw_state(...) to drive invalid:* validation styles |
checkbox(...) |
accent-*, border, rounded-*, checked:*, cursor-pointer |
accent-* sets the checked box fill color |
scrollable(...) |
overflow-y-auto, scrollbar-thin, scrollbar-none, scrollbar-thumb-*, scrollbar-track-* |
Pair with max-h-* or min-h-0 inside flex columns |
svg(...) |
w-*, h-*, opacity-* |
Use svg_tw / svg_handle_tw for CSS fill-* and stroke-* |
Controlled State Styling with .tw_state(...)
Section titled “Controlled State Styling with .tw_state(...)”Pass an explicit IssNodeState when a state comes from your app model (such as form validation or selection).
use iced::widget::{button, text, text_input};use iss::{tw, IssNodeState, TwExt};
let input = text_input("Email", &state.email) .on_input(Message::EmailChanged) .tw_state( tw!("px-3 py-2 bg-zinc-900 border border-zinc-700 focus:border-violet-400 invalid:border-rose-500 rounded-lg"), if state.email_valid { IssNodeState::EMPTY } else { IssNodeState::INVALID }, );
let save_btn = button(text("Save").tw(tw!("text-sm font-medium text-white"))) .on_press(Message::Save) .tw(tw!("px-4 py-2 bg-violet-600 hover:bg-violet-500 active:bg-violet-700 rounded-lg cursor-pointer"));use iced::widget::{button, text, text_input};use iss::typed::*;
let input_style = IssStyle::new() .px(3) .py(2) .bg(palette::ZINC_900) .border() .border_color(palette::ZINC_700) .focus(|s| s.border_color(palette::VIOLET_400)) .invalid(|s| s.border_color(palette::ROSE_500)) .rounded_lg();
let save_style = IssStyle::new() .px(4) .py(2) .bg(palette::VIOLET_600) .hover(|s| s.bg(palette::VIOLET_500)) .active(|s| s.bg(palette::VIOLET_700)) .rounded_lg() .cursor_pointer();
let input = text_input("Email", &state.email) .on_input(Message::EmailChanged) .tw_state(input_style, if state.email_valid { IssNodeState::EMPTY } else { IssNodeState::INVALID });
let save_btn = button(text("Save").tw(IssStyle::new().text_sm().font_medium().text_color(palette::WHITE))) .on_press(Message::Save) .tw(save_style);Multi-Child Layouts: row_tw, col_tw, flex_tw, grid_tw
Section titled “Multi-Child Layouts: row_tw, col_tw, flex_tw, grid_tw”Iced keeps the children inside Row and Column private, so ISS provides layout helpers that handle gap-*, justify-*, items-*, wrapping, 2D grids, divide-*, and structural child selectors (first:*, odd:*, peer-*).
use iced::widget::{button, container, text};use iss::{col_tw, flex_tw, grid_tw, row_tw, tw, TwExt};
// Horizontal toolbar with spaced actionslet toolbar = row_tw( [ text("Releases").tw(tw!("text-base font-semibold text-white")), button(text("New").tw(tw!("text-xs font-semibold text-white"))) .on_press(Message::NewRelease) .tw(tw!("px-3 py-1.5 bg-violet-600 hover:bg-violet-500 rounded-lg cursor-pointer")), ], tw!("w-full items-center justify-between gap-4"),);
// Wrapping tag barlet tags = flex_tw( [ container(text("v0.2.0").tw(tw!("text-xs text-violet-200"))).tw(tw!("px-2.5 py-1 bg-violet-500/20 rounded-full")), container(text("iced 0.14").tw(tw!("text-xs text-zinc-200"))).tw(tw!("px-2.5 py-1 bg-zinc-800 rounded-full")), container(text("tailwind v4").tw(tw!("text-xs text-zinc-200"))).tw(tw!("px-2.5 py-1 bg-zinc-800 rounded-full")), ], tw!("flex-row flex-wrap gap-2"),);
// 2D grid with sidebar + fluid content tracklet shell = grid_tw( [ container(text("Sidebar").tw(tw!("text-sm text-zinc-300"))).tw(tw!("p-4 bg-zinc-900 rounded-xl")), col_tw([toolbar, tags], tw!("p-4 gap-4 bg-zinc-900 rounded-xl")), ], tw!("w-full grid-cols-[220px_1fr] gap-4"),);use iced::widget::{button, container, text};use iss::typed::*;
let toolbar = row_tw( [ text("Releases").tw(IssStyle::new().text_base().font_semibold().text_color(palette::WHITE)), button(text("New").tw(IssStyle::new().text_xs().font_semibold().text_color(palette::WHITE))) .on_press(Message::NewRelease) .tw(IssStyle::new().px(3).py(1.5).bg(palette::VIOLET_600).hover(|s| s.bg(palette::VIOLET_500)).rounded_lg().cursor_pointer()), ], IssStyle::new().w_full().items_center().justify_between().gap(4),);
let tags = flex_tw( [ container(text("v0.2.0").tw(IssStyle::new().text_xs().text_color(palette::VIOLET_200))) .tw(IssStyle::new().px(2.5).py(1).bg(palette::VIOLET_500.alpha(0.2)).rounded_full()), container(text("iced 0.14").tw(IssStyle::new().text_xs().text_color(palette::ZINC_200))) .tw(IssStyle::new().px(2.5).py(1).bg(palette::ZINC_800).rounded_full()), ], IssStyle::new().flex_row().flex_wrap().gap(2),);
let shell = grid_tw( [ container(text("Sidebar").tw(IssStyle::new().text_sm().text_color(palette::ZINC_300))) .tw(IssStyle::new().p(4).bg(palette::ZINC_900).rounded_xl()), col_tw([toolbar, tags], IssStyle::new().p(4).gap(4).bg(palette::ZINC_900).rounded_xl()), ], IssStyle::new().w_full().grid_cols(2).gap(4),);Other specialized multi-child helpers available in iss: stack_tw (layered absolute overlays and z-*), list_tw (list-disc / marker:*), table_tw (border-collapse), and columns_tw (multi-column flows).