Fieldset is a grouping component with a content toggle feature.
import { Fieldset } from 'primereact/fieldset';
<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/fieldset/fieldset.min.js"></script>
Panel is a container component that accepts content as its children.
<Fieldset legend="Header">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</Fieldset>
Instead of simple strings, legend propery also can be used to provide custom content as JSX.
Content of the fieldset can be expanded and collapsed using toggleable option. A toggleable fieldset can either be used as a Controlled or Uncontrolled component.
In controlled mode, collapsed and onToggle properties need to be defined to control the collapsed state.
<Fieldset legend="Header" toggleable collapsed={this.state.panelCollapsed} onToggle={(e) => this.setState({panelCollapsed: e.value})}>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</Fieldset>
In uncontrolled mode, only toggleable property needs to be enabled. Initial state can be still be provided using the collapsed property in uncontrolled mode however it is evaluated at initial rendering and ignored in further updates. If you programmatically need to update the collapsed state, prefer to use the component as controlled.
<Fieldset legend="Header" toggleable>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</Fieldset>
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
legend | string | null | Header text of the fieldset. |
className | string | null | Style class of the element. |
style | object | null | Inline style of the element. |
toggleable | boolean | false | When specified, content can toggled by clicking the legend. |
collapsed | boolean | false | Defines the default visibility state of the content. |
transitionOptions | object | null | The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties. |
Name | Parameters | Description |
---|---|---|
onCollapse | event.originalEvent: Browser event | Callback to invoke when an active tab is collapsed by clicking on the header. |
onExpand | event.originalEvent: Browser event | Callback to invoke when a tab gets expanded. |
onToggle | event.originalEvent: browser event event.value: Collapsed state as a boolean | Callback to invoke when a tab gets expanded. |
onClick | event Browser event | Callback to invoke when fieldset is clicked. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-fieldset | Fieldset element. |
p-fieldset-toggleable | Toggleable fieldset element. |
p-fieldset-legend | Legend element. |
p-fieldset-content | Content element. |
This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.
None.
Built-in component themes created by the PrimeReact Theme Designer.
Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.
Beautifully crafted premium create-react-app application templates by the PrimeTek design team.