Skip to main content

Introduction

Within Filament schemas, prime components are the most basic building blocks that can be used to insert arbitrary content into a schema, such as text and images. As the name suggests, prime components are not divisible and cannot be made simpler. Filament provides a set of built-in prime components: You may also create your own custom components to add your own arbitrary content to a schema. In this example, prime components are being used to display instructions to the user, a QR code that the user can scan, and list of recovery codes that the user can save:
Although text can be rendered in a schema using an infolist text entry, entries are intended to render a label-value detail about an entity (like an Eloquent model), and not to render arbitrary text. Prime components are more suitable for this purpose. Infolists can be considered more similar to description lists in HTML. Prime component classes can be found in the Filament\Schemas\Components namespace. They reside within the schema array of components.

Text component

Text can be inserted into a schema using the Text component. Text content is passed to the make() method:
To render raw HTML content, you can pass an HtmlString object to the make() method:
Be aware that you will need to ensure that the HTML is safe to render, otherwise your application will be vulnerable to XSS attacks.
To render Markdown, you can use Laravel’s str() helper to convert Markdown to HTML, and then transform it into an HtmlString object:

Customizing the text color

You may set a color for the text:

Using a neutral color

By default, the text color is set to gray, which is typically fairly dim against its background. You can darken it using the color('neutral') method:

Displaying as a “badge”

By default, text is quite plain and has no background color. You can make it appear as a “badge” instead using the badge() method. A great use case for this is with statuses, where may want to display a badge with a color that matches the status:
Optionally, you may pass a boolean value to control if the text should be in a badge or not:

Adding an icon to the badge

You may add other things to the badge, like an icon:

Customizing the text size

Text has a small font size by default, but you may change this to TextSize::ExtraSmall, TextSize::Medium, or TextSize::Large. For instance, you may make the text larger using size(TextSize::Large):

Customizing the font weight

Text entries have regular font weight by default, but you may change this to any of the following options: FontWeight::Thin, FontWeight::ExtraLight, FontWeight::Light, FontWeight::Medium, FontWeight::SemiBold, FontWeight::Bold, FontWeight::ExtraBold or FontWeight::Black. For instance, you may make the font bold using weight(FontWeight::Bold):

Customizing the font family

You can change the text font family to any of the following options: FontFamily::Sans, FontFamily::Serif or FontFamily::Mono. For instance, you may make the font monospaced using fontFamily(FontFamily::Mono):

Adding a tooltip to the text

You may add a tooltip to the text using the tooltip() method:

Using JavaScript to determine the content of the text

You can use JavaScript to determine the content of the text. This is useful if you want to display a different message depending on the state of a form field, without making a request to the server to re-render the schema. To allow this, you can use the js() method:
The $state and $get() utilities are available in the JavaScript context, so you can use them to get the state of fields in the schema.

Icon component

Icons can be inserted into a schema using the Icon component. Icons are passed to the make() method:

Customizing the icon color

You may set a color for the icon:

Customizing the icon size

The default icon size is IconSize::Medium, but you may customize the size to be either IconSize::ExtraSmall, IconSize::Small, IconSize::Large, IconSize::ExtraLarge or IconSize::TwoExtraLarge:

Adding a tooltip to the icon

You may add a tooltip to the icon using the tooltip() method:

Image component

Images can be inserted into a schema using the Image component. The image URL and alt text are passed to the make() method:

Customizing the image size

You may customize the image size by passing a imageWidth() and imageHeight(), or both with imageSize():

Aligning the image

You may align the image to the start (left in left-to-right interfaces, right in right-to-left interfaces), center, or end (right in left-to-right interfaces, left in right-to-left interfaces) using the alignStart(), alignCenter() or alignEnd() methods:
Alternatively, you may pass an Alignment enum to the alignment() method:

Adding a tooltip to the image

You may add a tooltip to the image using the tooltip() method:

Unordered list component

Unordered lists can be inserted into a schema using the UnorderedList component. The list items, comprising plain text or text components, are passed to the make() method:
Text components can be used as list items, which allows you to customize the formatting of each item:

Customizing the bullet size

If you are modifying the text size of the list content, you will probably want to adjust the size of the bullets to match. To do this, you can use the size() method. Bullets have small font size by default, but you may change this to TextSize::ExtraSmall, TextSize::Medium, or TextSize::Large. For instance, you may make the bullets larger using size(TextSize::Large):

Adding extra HTML attributes to a prime component

You can pass extra HTML attributes to the component via the extraAttributes() method, which will be merged onto its outer HTML element. The attributes should be represented by an array, where the key is the attribute name and the value is the attribute value:
By default, calling extraAttributes() multiple times will overwrite the previous attributes. If you wish to merge the attributes instead, you can pass merge: true to the method.