Skip to content
# Card ## Description Card is the surface a single subject lives on. On its own it is a padded box with the corner, the paint and the shadow of the current theme; give it a title, an icon, a cover picture, a row of actions or a footer and it lays those parts out for you, edge to edge where the picture needs it and inset everywhere else. The cover can sit above the content, beside it, after it, or behind it as a hero, cropped to a height or an aspect ratio of your own. It comes in three sizes and across the whole color palette in three variants, with a 25-step elevation ramp, an outline instead of a shadow and square corners. Give it a click handler and it becomes a real control that answers Enter and Space; give it a URL and it lays an accessible block link over its own surface without swallowing the buttons in its header and footer; bind its Selected value and it becomes a card a reader can pick. ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Actions | `RenderFragment?` | null | The content rendered at the trailing edge of the header of the card, for whatever acts on the card as a whole. It is raised above the stretched link of a card that has an Href, so the controls in it stay clickable. | | Background | `BitColorKind?` | null | The color kind of the background of the card. | | Border | `BitColorKind?` | null | The color kind of the border of the card. | | ChildContent | `RenderFragment?` | null | The content of the card. It renders on its own inside the padding of the card, unless the card also has a cover, a header or a footer - then it renders as the body between them. | | Classes | `BitCardClassStyles?` | null | Custom CSS classes for different parts of the card. | | Color | `BitColor?` | null | The general color of the card. Setting it paints the card in one of the roles of the theme instead of in the neutral surface colors, in the way the Variant asks for. | | Cover | `RenderFragment?` | null | The full-bleed media at the head of the card, rendered outside the padding and clipped to the corner of the card. It takes precedence over ImageUrl. | | CoverOverlay | `bool` | false | Lays the cover of the card behind its content instead of above it, filling the whole surface. The card needs a Height or a MinHeight of its own, since an overlaid cover no longer makes it as tall as the picture. | | CoverRatio | `string?` | null | The aspect ratio the cover of the card is drawn at, as a CSS ratio such as 16 / 9. The cover is then sized by the ratio rather than by the picture inside it, which keeps a row of cards level while the column narrows. | | CoverWidth | `string?` | null | The width of the cover of a horizontal card. The default is a third of the width of the card. | | Divider | `bool` | false | Draws a hairline between the header and the body of the card and between its body and its footer. A part on the outer edge of the stack - a header with nothing under it, a footer with nothing over it - draws no rule of its own. | | Download | `string?` | null | The download attribute of the stretched link of the card. | | Elevation | `int?` | null | Sets the shadow elevation level of the card (0-24). Maps to theme shadow variables (--bit-shd-1 to --bit-shd-24), with 0 being a card with no shadow at all. | | Footer | `RenderFragment?` | null | The content rendered under the body of the card, for the actions a reader is meant to take. It is raised above the stretched link of a card that has an Href, so the controls in it stay clickable. | | FloatingActions | `RenderFragment?` | null | The content floated over the leading corner of the card, above everything else on its surface - the corner a picture card keeps its favourite toggle or its selection box in. It is raised above the stretched link of a card that has an Href, so the control in it stays clickable. | | FullHeight | `bool` | false | Makes the card height 100% of its parent container. | | FullSize | `bool` | false | Makes the card width and height 100% of its parent container. | | FullWidth | `bool` | false | Makes the card width 100% of its parent container. | | HeaderTemplate | `RenderFragment?` | null | The custom template rendered as the header of the card, in place of the icon, the title and the subtitle. Actions still renders beside it. | | HeadingLevel | `int?` | null | The heading level the title of the card reports itself as (1-6). Leaving it unset keeps the title plain text. Values outside 1-6 are ignored. | | Height | `string?` | null | Sets the height of the card explicitly. | | Horizontal | `bool` | false | Lays the cover of the card beside its content instead of above it. | | Hoverable | `bool` | false | Lifts the card while the pointer is over it. A clickable card or a linked one lifts on its own. | | Href | `string?` | null | The URL the whole card leads to, rendered as an anchor stretched over the surface of the card. The anchor is named by the AriaLabel, or failing that by the Title or the Subtitle of the card. | | Icon | `BitIconInfo?` | null | The leading icon of the header of the card. | | IconName | `string?` | null | The name of the leading icon of the header of the card. | | IconTemplate | `RenderFragment?` | null | The custom template rendered in the leading slot of the header of the card, in place of the icon. Unlike HeaderTemplate it keeps the Title and the Subtitle beside it. | | ImageAlt | `string?` | null | The alternate text of the cover image of the card. With no value it renders an empty alt, so the picture is skipped by assistive technologies. | | ImageHeight | `string?` | null | The height of the cover image of the card. The image is cropped to fill it rather than stretched. | | ImageLoading | `BitImageLoading?` | null | The loading behavior of the cover image of the card, eager or lazy. | | ImagePosition | `string?` | null | The part of the cover image of the card that is kept in frame, as a CSS object-position such as top or 50% 20%. It only means anything on a cover that crops the picture, through ImageHeight or CoverRatio. | | ImageUrl | `string?` | null | The URL of the cover image at the head of the card. | | Loading | `bool` | false | Stands the body of the card in with a placeholder while its content is being fetched, and reports the card as busy. The header keeps rendering. | | LoadingTemplate | `RenderFragment?` | null | The custom placeholder rendered in the body of the card while Loading is set. | | MaxHeight | `string?` | null | Sets the maximum height of the card. | | MaxWidth | `string?` | null | Sets the maximum width of the card. | | MinHeight | `string?` | null | Sets the minimum height of the card. | | MinWidth | `string?` | null | Sets the minimum width of the card. | | NoPadding | `bool` | false | Removes the default padding of the card. | | NoShadow | `bool` | false | Removes the default shadow around the card. | | OnClick | `EventCallback<MouseEventArgs>` | | The callback for when the card is clicked. Setting it turns the card into a button: it takes focus, it answers Enter and Space, and it reports itself as a control to assistive technologies. | | Outlined | `bool` | false | Renders the card with no shadow and a primary border. An explicit Border still wins over the border color it asks for. | | Rel | `BitLinkRels?` | null | The rel attribute of the stretched link of the card. With no value of its own, a card whose Target is _blank gets noopener. | | Reversed | `bool` | false | Lays the cover of the card after its content instead of before it: under the body on a vertical card, on the trailing edge of a Horizontal one. | | ScrollableBody | `bool` | false | Lets the content of the card scroll inside it instead of growing past the height it was given. It only means anything on a card whose height is bounded. | | Selected | `bool` | false | Whether the card is currently selected. Binding it turns the card into a toggle: clicking it flips the value, and the card reports its state through aria-pressed as a button, or through aria-selected where it was given a role that carries one. | | Size | `BitSize?` | null | The size of the card, which sets its padding, the gap between its parts and the type of its header. | | Square | `bool` | false | Removes the border-radius from the card, rendering it with sharp corners. | | StopPropagation | `bool` | false | Stops the propagation of the click event of the card. | | Styles | `BitCardClassStyles?` | null | Custom CSS styles for different parts of the card. | | Subtitle | `string?` | null | The second line of the header of the card, under the title. | | Target | `string?` | null | The target attribute of the stretched link of the card. | | Title | `string?` | null | The title of the card, rendered as the first line of its header. It also names the stretched link of a card that has an Href. | | Variant | `BitVariant?` | null | The visual variant of the card, which only takes effect while a Color is set. The default is Fill. | | Width | `string?` | null | Sets the width of the card explicitly. | | AriaLabel | `string?` | null | Gets or sets the accessible label for the component, used by assistive technologies. | | Class | `string?` | null | Gets or sets the CSS class name(s) to apply to the rendered element. | | Dir | `BitDir?` | null | Gets or sets the text directionality for the component's content. | | ForceAnimation | `bool` | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. | | HtmlAttributes | `Dictionary<string, object>` | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. | | Id | `string?` | null | Gets or sets the unique identifier for the component's root element. | | IsEnabled | `bool` | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. | | Style | `string?` | null | Gets or sets the CSS style string to apply to the rendered element. | | TabIndex | `string?` | null | Gets or sets the tab order index for the component when navigating with the keyboard. | | Visibility | `BitVisibility` | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. | ## Public Members | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | FocusAsync | `ValueTask` | | Gives focus to the card, which only lands anywhere while the card is a control or has a tab index of its own. | | UniqueId | `Guid` | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. | | RootElement | `ElementReference` | | Gets the reference to the root HTML element associated with this component. | ## Enums ### BitColorKind Enum | Name | Value | Description | | :--- | :--- | :---------- | | Primary | 0 | The primary color kind. | | Secondary | 1 | The secondary color kind. | | Tertiary | 2 | The tertiary color kind. | | Transparent | 3 | The transparent color kind. | ### BitColor Enum | Name | Value | Description | | :--- | :--- | :---------- | | Primary | 0 | Primary general color. | | Secondary | 1 | Secondary general color. | | Tertiary | 2 | Tertiary general color. | | Info | 3 | Info general color. | | Success | 4 | Success general color. | | Warning | 5 | Warning general color. | | SevereWarning | 6 | SevereWarning general color. | | Error | 7 | Error general color. | | PrimaryBackground | 8 | Primary background color. | | SecondaryBackground | 9 | Secondary background color. | | TertiaryBackground | 10 | Tertiary background color. | | PrimaryForeground | 11 | Primary foreground color. | | SecondaryForeground | 12 | Secondary foreground color. | | TertiaryForeground | 13 | Tertiary foreground color. | | PrimaryBorder | 14 | Primary border color. | | SecondaryBorder | 15 | Secondary border color. | | TertiaryBorder | 16 | Tertiary border color. | ### BitImageLoading Enum | Name | Value | Description | | :--- | :--- | :---------- | | Eager | 0 | The default behavior of the browser: the image is fetched as soon as the img element is processed. | | Lazy | 1 | The image is fetched only once the browser estimates that it is about to be needed. | ### BitSize Enum | Name | Value | Description | | :--- | :--- | :---------- | | Small | 0 | The small size. | | Medium | 1 | The medium size. | | Large | 2 | The large size. | ### BitVariant Enum | Name | Value | Description | | :--- | :--- | :---------- | | Fill | 0 | Fill styled variant. | | Outline | 1 | Outline styled variant. | | Text | 2 | Text styled variant. | ### BitLinkRels Enum | Name | Value | Description | | :--- | :--- | :---------- | | Alternate | 1 | Provides a link to an alternate representation of the document. (i.e. print page, translated or mirror) | | Author | 2 | Provides a link to the author of the document. | | Bookmark | 4 | Permanent URL used for bookmarking. | | External | 8 | Indicates that the referenced document is not part of the same site as the current document. | | Help | 16 | Provides a link to a help document. | | License | 32 | Provides a link to licensing information for the document. | | Next | 64 | Provides a link to the next document in the series. | | NoFollow | 128 | Links to an unendorsed document, like a paid link. ("NoFollow" is used by Google, to specify that the Google search spider should not follow that link) | | NoOpener | 256 | Requires that any browsing context created by following the hyperlink must not have an opener browsing context. | | NoReferrer | 512 | Makes the referrer unknown. No referrer header will be included when the user clicks the hyperlink. | | Prev | 1024 | The previous document in a selection. | | Search | 2048 | Links to a search tool for the document. | | Tag | 4096 | A tag (keyword) for the current document. | | Me | 8192 | Indicates that the linked document represents the person who owns the current content. (used for identity verification) | | Opener | 16384 | Requires that any browsing context created by following the hyperlink keeps its opener browsing context. (reverses the implicit noopener modern browsers apply to _blank targets) | | PrivacyPolicy | 32768 | Links to the privacy policy that applies to the current document. (rendered as privacy-policy) | | Sponsored | 65536 | Marks the link as an advertisement or paid placement, so search engines do not count it as an organic endorsement. | | TermsOfService | 131072 | Links to the terms of service that apply to the current document. (rendered as terms-of-service) | | Ugc | 262144 | Marks the link as user-generated content, like forum posts or comments, for search engines. | ### BitVisibility Enum | Name | Value | Description | | :--- | :--- | :---------- | | Visible | 0 | The content of the component is visible. | | Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). | | Collapsed | 2 | The component is hidden (display:none). | ### BitDir Enum | Name | Value | Description | | :--- | :--- | :---------- | | Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). | | Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). | | Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. | ## Sub Classes ### BitCardClassStyles Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Root | `string?` | null | Custom CSS classes/styles for the root element of the BitCard. | | Link | `string?` | null | Custom CSS classes/styles for the stretched link that covers a card with an Href. | | FloatingActions | `string?` | null | Custom CSS classes/styles for the slot floated over the corner of the BitCard. | | Cover | `string?` | null | Custom CSS classes/styles for the full-bleed media area at the head of the BitCard. | | Image | `string?` | null | Custom CSS classes/styles for the image rendered from the ImageUrl of the BitCard. | | Main | `string?` | null | Custom CSS classes/styles for the element that holds the header, the body and the footer of the BitCard. | | Header | `string?` | null | Custom CSS classes/styles for the header of the BitCard. | | Icon | `string?` | null | Custom CSS classes/styles for the leading icon of the header of the BitCard. | | HeaderText | `string?` | null | Custom CSS classes/styles for the element that holds the title and the subtitle of the BitCard. | | Title | `string?` | null | Custom CSS classes/styles for the title of the BitCard. | | Subtitle | `string?` | null | Custom CSS classes/styles for the subtitle of the BitCard. | | Actions | `string?` | null | Custom CSS classes/styles for the actions rendered at the trailing edge of the header of the BitCard. | | Body | `string?` | null | Custom CSS classes/styles for the body of the BitCard, which is what the ChildContent renders into. | | Footer | `string?` | null | Custom CSS classes/styles for the footer of the BitCard. | | Selected | `string?` | null | Custom CSS classes/styles for the root element of the BitCard while it is selected. | ## Examples \n**Basic**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more ``` \n**Header**: ```razor bit BlazorUI components are native, easy-to-customize, and ... A title given a heading level reports itself as one to assistive technologies. An IconTemplate leads the header and leaves the title and the subtitle where they are. A HeaderTemplate takes the place of the icon, the title and the subtitle. ``` \n**Cover**: ```razor A cover runs edge to edge and is clipped to the corner of the card. A cover given a ratio stays at that ratio however wide the card ends up. The crop is taken from the top rather than from the middle. Reversed puts the header and the body over the picture instead of under it.
bit BlazorUI
The Cover template takes the place of the image.
An overlaid cover fills the card and the content is written over it.
Explore
``` \n**Actions & Footer**: ```razor Actions sit beside the title; the footer sits under the body.
Open Share
The star floats over the picture. Starred: @isStarred And the same card with a rule between each part and the next.
Open Share
``` ```csharp private bool isStarred; ``` \n**Horizontal**: ```razor A horizontal card is a thumbnail and a summary on one row. CoverWidth pins the thumbnail to a fixed width. Reversed puts the thumbnail after the words instead of before them. ``` \n**Click**: ```razor Clicked @clickCount times. This one answers nothing. ``` ```csharp private int clickCount; ``` \n**Link**: ```razor The whole surface is the link; the pin button above it is not. Pinned: @isPinned
GitHub
``` ```csharp private bool isPinned; ``` \n**Selection**: ```razor Selected: @isBasicSelected Selected: @isProSelected ``` ```csharp private bool isProSelected; private bool isBasicSelected = true; ``` \n**Hoverable**: ```razor The shadow answers the pointer. ``` \n**Loading**: ```razor Once it is loaded, this is what the card had to say. And this one brought its own placeholder. ``` ```csharp private bool isLoading = true; ``` \n**Elevation**: ```razor
bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more
``` ```csharp private double elevation = 4; ``` \n**NoShadow**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more ``` \n**Background**: ```razor
bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more
``` ```csharp private BitColorKind backgroundColorKind = BitColorKind.Primary; ``` \n**Border**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more ``` ```csharp private BitColorKind borderColorKind = BitColorKind.Primary; ``` \n**Outlined**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more ``` \n**Square**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more ``` \n**NoPadding**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more ``` \n**Width & Height**: ```razor bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more This one is bounded rather than sized: it never shrinks below 12rem and never grows past 24rem. @for (var i = 1; i <= 12; i++) { Line @i of a body that outgrew its card. }
Close
``` ```csharp private double cardWidth = 300; private double cardHeight = 200; ``` \n**FullSize**: ```razor
bit BlazorUI bit BlazorUI components are native, easy-to-customize, and ... Learn more
``` ```csharp private int size = 0; ``` \n**Accessibility**: ```razor A named card is a group, and its title is a level-3 heading. Out of the tab order, off the pointer, marked disabled. ``` \n**Color**: ```razor
``` \n**External Icons**: ```razor ``` \n**Size**: ```razor Small padding, small type. Medium padding, medium type. Large padding, large type. ``` \n**Style & Class**: ```razor Styled card Classed card Every part can be styled on its own. And every part can take a class. ``` \n**RTL**: ```razor بیت بلیزور یو آی، کامپوننت‌های بومی، قابل تنظیم و ...
باز کردن
```