Skip to content
IzzyBlazor 0.1.0-alpha.17

Enter all results ↑ ↓ move Esc close

Box

A plain block that takes every style prop.

A static page with IzzyBlazor's script. No circuit.

The base surface. Renders one element with the style props applied; every other layout primitive is a Box with defaults.

Usage

razor
<Box As="section" Padding="new() { Base = 6, Md = 10 }" Bg="Color.Fill" Radius="Radius.Md">...</Box>

Bands, borders and a dashed card

Preview

A band: Bg, BorderY="1", padding.

A box with Border, BorderColor and Radius.

New project

Code

Borders.razor
@* Surface props on boxes: a band with lines above and below, a bordered box, and a dashed card
   for an "add new" tile. *@
<Stack Gap="4" Grow>
    <Box Bg="Color.FillSubtle" BorderY="1" PaddingX="4" PaddingY="3">
        <TextBlock Size="TextSize.Sm">A band: <Code>Bg</Code>, <Code>BorderY="1"</Code>, padding.</TextBlock>
    </Box>
    <Grid Columns="new() { Base = 1, Sm = 2 }" Gap="4">
        <Box Border="1" BorderColor="Color.Outline" Radius="Radius.Lg" Padding="4">
            <TextBlock Size="TextSize.Sm">A box with <Code>Border</Code>, <Code>BorderColor</Code> and <Code>Radius</Code>.</TextBlock>
        </Box>
        <Card BorderStyle="BorderStyle.Dashed" Size="ControlSize.Sm">
            <Row Gap="2" Align="Align.Center">
                <Icon Name="Lucide.Plus" />
                <TextBlock Size="TextSize.Sm">New project</TextBlock>
            </Row>
        </Card>
    </Grid>
</Stack>

A scheme for part of a page

Preview

Dark

ColorScheme.Dark

Pending

Inverse

ColorScheme.Inverse, the opposite of the page

Live

Code

Scheme.razor
@* A dark part of a light page, and one that's always the opposite of the page (Inverse). Every
   token switches inside, so text, buttons and badges keep their contrast. *@
<Grid Columns="new() { Base = 1, Sm = 2 }" Gap="4" Grow>
    <Card Title="Dark" Description="ColorScheme.Dark" ColorScheme="ColorScheme.Dark">
        <Row Gap="2" Wrap Align="Align.Center">
            <Button>Deploy</Button>
            <Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral">Logs</Button>
            <Badge Status="Status.Warning">Pending</Badge>
        </Row>
    </Card>
    <Card Title="Inverse" Description="ColorScheme.Inverse, the opposite of the page" ColorScheme="ColorScheme.Inverse">
        <Row Gap="2" Wrap Align="Align.Center">
            <Button>Deploy</Button>
            <Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral">Logs</Button>
            <Badge Status="Status.Success">Live</Badge>
        </Row>
    </Card>
</Grid>

Surfaces

Use Bg with the surface colors: Background for the page, Surface for cards on it, the three fills (FillSubtle, Fill, FillStrong) inside a surface, each a step further from it, and SurfaceOverlay for what floats above, with a Border and a Shadow.

Preview

Background

Surface

FillSubtle
Fill
FillStrong
SurfaceOverlay

A menu or popover

Code

Surfaces.razor
@* Each color where it's used: the page, a card on it (Surface), fills inside the card, each a step
   further from it, and an overlay with a border and a shadow, as menus and popovers draw
   over the card. *@
<Box Padding="4" Bg="Color.Background" Border="1" Radius="Radius.Lg" Grow>
    <Stack Gap="3">
        <TextBlock Size="TextSize.Sm" Color="Color.Muted">Background</TextBlock>
        <Box Padding="4" Bg="Color.Surface" Border="1" Radius="Radius.Lg">
            <Stack Gap="3">
                <TextBlock Size="TextSize.Sm" Color="Color.Muted">Surface</TextBlock>
                <Grid Columns="new() { Base = 1, Sm = 3 }" Gap="3">
                    <Box Padding="3" Bg="Color.FillSubtle" Radius="Radius.Md">FillSubtle</Box>
                    <Box Padding="3" Bg="Color.Fill" Radius="Radius.Md">Fill</Box>
                    <Box Padding="3" Bg="Color.FillStrong" Radius="Radius.Md">FillStrong</Box>
                </Grid>
                <Box Padding="3" Bg="Color.SurfaceOverlay" Border="1" Shadow="Shadow.Lg" Radius="Radius.Lg" MaxWidth="Length.Rem(16)">
                    SurfaceOverlay
                    <TextBlock Size="TextSize.Sm" Color="Color.Muted">A menu or popover</TextBlock>
                </Box>
            </Stack>
        </Box>
    </Stack>
</Box>

Text on a color

Set Bg to a theme color and the text takes its matching on-color by itself; set Color to choose your own, as on the soft box.

Preview

Primary
Success
Warning
Danger
PrimarySoft with PrimaryText

Code

Contrast.razor
<Row Gap="3" Wrap Grow>
    <Box Bg="Color.Primary" Padding="4" Radius="Radius.Md" Grow>Primary</Box>
    <Box Bg="Color.Success" Padding="4" Radius="Radius.Md" Grow>Success</Box>
    <Box Bg="Color.Warning" Padding="4" Radius="Radius.Md" Grow>Warning</Box>
    <Box Bg="Color.Danger" Padding="4" Radius="Radius.Md" Grow>Danger</Box>
    <Box Bg="Color.PrimarySoft" Color="Color.PrimaryText" Padding="4" Radius="Radius.Md" Grow>PrimarySoft with PrimaryText</Box>
</Row>

Element and reading width

Use As to render another element, here an article, and MaxWidth="Length.Prose" to stop at a comfortable line length (68ch).

Preview

Release 2.4

Invoices can now be paid in installments. Choose a plan when you send one, and we'll remind your customer before each payment is due. Existing invoices aren't affected.

Code

Element.razor
<Box As="article" MaxWidth="Length.Prose" Padding="6" Bg="Color.FillSubtle" Radius="Radius.Lg">
    <Column Gap="2">
        <Heading Level="3">Release 2.4</Heading>
        <TextBlock Color="Color.Muted">
            Invoices can now be paid in installments. Choose a plan when you send one, and we'll
            remind your customer before each payment is due. Existing invoices aren't affected.
        </TextBlock>
    </Column>
</Box>

Showing by breakpoint

Use HiddenFrom and VisibleFrom to swap content at a breakpoint: from Sm (640px), the button shows its label; on phones it's an icon button.

Preview

Invoices

Code

Visibility.razor
<Row Gap="2" Align="Align.Center" PaddingY="3" BorderBottom="1" Grow>
    <TextBlock As="span" Size="TextSize.Lg" Weight="FontWeight.Semibold">Invoices</TextBlock>
    <Spacer />
    <IconButton Icon="Lucide.Plus" Label="New invoice" HiddenFrom="Breakpoint.Sm" />
    <Button StartIcon="Lucide.Plus" VisibleFrom="Breakpoint.Sm">New invoice</Button>
</Row>

Mode support

What works in each mode, Box
FeatureOffStaticLive
EverythingYesYesYes

Off: JavaScript disabled. Static: a static SSR page with IzzyBlazor's script. Live: an interactive page (Server, WebAssembly or Auto).

Accessibility

  • It renders a div; As makes it another element, such as nav or ul, so a landmark or list needs no extra wrapper.
  • Attributes it doesn't take as parameters, such as role or aria-label, go on the element.

Parameters

Box parameters
PropTypeDefault
AsThe element to render: div on a Box; components built on it set their own (List a ul, Section a section).string"div"
ChildContentThe content.RenderFragment?

See also

  • Stack: a row or a column, changing with the screen width.
  • Grid: columns by breakpoint, by minimum width, or by template.
  • Section: a full-width band of a page, such as a hero.
  • Container: centers content at a readable width.