Skip to content

Arbitrary Values & Escape Hatches

When design tokens or standard spacing steps are not exact enough, ISS supports Tailwind CSS v4 arbitrary bracket syntax, opacity modifiers, negative values, !important, calc(), CSS variables, and direct escape hatches back to raw Iced widget methods.

Use [...] anywhere you need an exact pixel size, percentage, color, grid track list, or custom box shadow. Underscores (_) inside brackets represent spaces, just like Tailwind CSS.

Category Example Effect
Exact sizing & padding w-[324px], h-[52px], p-[18px], gap-[14px] Exact pixel (or rem / %) dimensions
Custom corner radius rounded-[18px], rounded-t-[20px] Exact corner radii outside the named scale
Hex & RGB colors bg-[#120f1d], text-[rgb(245,208,254)] Exact color values with optional /alpha
Grid track lists grid-cols-[240px_1fr], grid-rows-[auto_1fr_48px] Fixed sidebars + fluid columns or rows
Custom shadows shadow-[0_12px_32px_rgba(0,0,0,0.45)] Arbitrary offset, blur, spread, and color
Type hints bg-[length:200px_100px], bg-[position:20%_40%] Disambiguates size/position from colors
use iced::widget::{container, text};
use iss::{grid_tw, tw, TwExt};
let layout = grid_tw(
[
container(text("Navigation").tw(tw!("text-sm text-zinc-300")))
.tw(tw!("p-[18px] rounded-[18px] bg-[#120f1d]/62 shadow-[0_12px_32px_rgba(0,0,0,0.45)]")),
container(text("Workspace").tw(tw!("text-sm text-white")))
.tw(tw!("w-[324px] p-[18px] rounded-[18px] bg-zinc-900 border border-white/10")),
],
tw!("grid-cols-[240px_1fr] gap-4"),
);

2. Opacity Modifiers, Negatives, and !important

Section titled “2. Opacity Modifiers, Negatives, and !important”
  • Opacity modifiers: Append /60 (percentage) or /[0.42] (arbitrary alpha) to any palette color, arbitrary hex color, or theme variable: bg-violet-500/60, bg-[#120f1d]/[0.42], border-white/15.
  • Negative values: Prefix margin, inset, translate, rotate, skew, or z-index utilities with -: -mt-2, -mx-4, -translate-x-1/2, -rotate-3, -z-10.
  • Important overrides: Both Tailwind v4 trailing ! (p-4!, hover:bg-rose-500!) and v3 leading ! (!p-4) override later non-important classes in the cascade or .mix() chain.
use iced::widget::{container, text};
use iss::{tw, TwExt};
let badge = container(text("LIVE").tw(tw!("text-xs font-bold text-rose-200")))
.tw(tw!("-mt-2 -rotate-3 px-2.5 py-1 bg-rose-500/[0.42] border border-rose-400/60 rounded-full p-2!"));

3. calc() and Custom Properties (var(--token))

Section titled “3. calc() and Custom Properties (var(--token))”

Fold arithmetic expressions at compile time with calc(...) (such as w-[calc(100px+2rem)], w-[calc(50%+25%)], or p-[calc(1rem+4px)]), or reference live theme_provider design tokens with Tailwind v4 shorthand (--token) or standard var(--token, fallback).

use iced::widget::{container, text};
use iss::{tw, TwExt};
let card = container(text("Adaptive width").tw(tw!("text-sm text-(--color-ink)")))
.tw(tw!(
"w-[calc(100px+2rem)] p-[var(--pad,16px)] rounded-(--radius-card) bg-[var(--color-surface,#18181b)]/90"
));

Because .tw(...) works on standard Iced widgets and returns an iced::Element, you can always drop back to raw Iced methods before .tw(...), or skip ISS entirely for a custom widget or canvas:

use iced::widget::{button, container, text};
use iced::Length;
use iss::{tw, TwExt};
// Configure raw Iced widget options first, then apply ISS styling:
let custom_btn = button(text("Submit").tw(tw!("text-sm font-semibold text-white")))
.width(Length::FillPortion(2))
.padding([10, 18])
.on_press(Message::Submit)
.tw(tw!("bg-violet-600 hover:bg-violet-500 rounded-xl cursor-pointer"));
// Or use a raw Iced container::Style closure for one-off custom painting
// and place it right inside an ISS row_tw / col_tw / grid_tw layout:
let raw_panel = container(text("Custom Iced widget"))
.width(Length::Fill)
.padding(16)
.style(container::rounded_box);