Pills

React Bootstrap 5 Pills component

Pills are quasi-navigation components which can highly improve website clarity and increase user experience.

Note: Read the API tab to find all available options and advanced customization


Basic example

Basic pills are divided into 2 main sections - Pills navs (containing nav-items) and Pills content (containing tab-panes).

Use useState to connect pills navs with pills content.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
          import React, { useState } from 'react';
          import {   
            MDBTabs,
            MDBTabsItem,
            MDBTabsLink,
            MDBTabsContent,
            MDBTabsPane
          } from 'mdb-react-ui-kit';
  
          export default function App() {
            const [basicActive, setBasicActive] = useState('tab1');

            const handleBasicClick = (value: string) => {
              if (value === basicActive) {
                return;
              }
          
              setBasicActive(value);
            };

            return (
              <>
                <MDBTabs pills className='mb-3'>
                  <MDBTabsItem>
                    <MDBTabsLink onClick={() => handleBasicClick('tab1')} active={basicActive === 'tab1'}>
                      Tab 1
                    </MDBTabsLink>
                  </MDBTabsItem>
                  <MDBTabsItem>
                    <MDBTabsLink onClick={() => handleBasicClick('tab2')} active={basicActive === 'tab2'}>
                      Tab 2
                    </MDBTabsLink>
                  </MDBTabsItem>
                  <MDBTabsItem>
                    <MDBTabsLink onClick={() => handleBasicClick('tab3')} active={basicActive === 'tab3'}>
                      Tab 3
                    </MDBTabsLink>
                  </MDBTabsItem>
                </MDBTabs>
    
                <MDBTabsContent>
                  <MDBTabsPane show={basicActive === 'tab1'}>Tab 1 content</MDBTabsPane>
                  <MDBTabsPane show={basicActive === 'tab2'}>Tab 2 content</MDBTabsPane>
                  <MDBTabsPane show={basicActive === 'tab3'}>Tab 3 content</MDBTabsPane>
                </MDBTabsContent>
              </>
            );
          }
          
        
    

Fill and justify

Force your .nav's contents to extend the full available width one of two modifier classes.

Fill

To proportionately fill all available space with your MDBTabsItems, use fill property. Notice that all horizontal space is occupied, but not every nav item has the same width.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
            import React, { useState } from 'react';
            import {   
              MDBTabs,
              MDBTabsItem,
              MDBTabsLink,
              MDBTabsContent,
              MDBTabsPane
            } from 'mdb-react-ui-kit';
    
            export default function App() {
              const [fillActive, setFillActive] = useState('tab1');

              const handleFillClick = (value: string) => {
                if (value === fillActive) {
                  return;
                }
            
                setFillActive(value);
              };

              return (
                <>
                  <MDBTabs pills fill className='mb-3'>
                    <MDBTabsItem>
                      <MDBTabsLink onClick={() => handleFillClick('tab1')} active={fillActive === 'tab1'}>
                        Link
                      </MDBTabsLink>
                    </MDBTabsItem>
                    <MDBTabsItem>
                      <MDBTabsLink onClick={() => handleFillClick('tab2')} active={fillActive === 'tab2'}>
                        Very very very very long link
                      </MDBTabsLink>
                    </MDBTabsItem>
                    <MDBTabsItem>
                      <MDBTabsLink onClick={() => handleFillClick('tab3')} active={fillActive === 'tab3'}>
                        Another link
                      </MDBTabsLink>
                    </MDBTabsItem>
                  </MDBTabs>
    
                  <MDBTabsContent>
                    <MDBTabsPane show={fillActive === 'tab1'}>Tab 1 content</MDBTabsPane>
                    <MDBTabsPane show={fillActive === 'tab2'}>Tab 2 content</MDBTabsPane>
                    <MDBTabsPane show={fillActive === 'tab3'}>Tab 3 content</MDBTabsPane>
                  </MDBTabsContent>
                </>
              );
            }
          
        
    

Justify

For equal-width elements, use justify property. All horizontal space will be occupied by nav links, but unlike the fill property above, every nav item will be the same width.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
            import React, { useState } from 'react';
            import {   
              MDBTabs,
              MDBTabsItem,
              MDBTabsLink,
              MDBTabsContent,
              MDBTabsPane
            } from 'mdb-react-ui-kit';
    
            export default function App() {
              const [justifyActive, setJustifyActive] = useState('tab1');

              const handleJustifyClick = (value: string) => {
                if (value === justifyActive) {
                  return;
                }
            
                setJustifyActive(value);
              };

              return (
                <>
                  <MDBTabs pills justify className='mb-3'>
                    <MDBTabsItem>
                      <MDBTabsLink onClick={() => handleJustifyClick('tab1')} active={justifyActive === 'tab1'}>
                        Link
                      </MDBTabsLink>
                    </MDBTabsItem>
                    <MDBTabsItem>
                      <MDBTabsLink onClick={() => handleJustifyClick('tab2')} active={justifyActive === 'tab2'}>
                        Very very very very long link
                      </MDBTabsLink>
                    </MDBTabsItem>
                    <MDBTabsItem>
                      <MDBTabsLink onClick={() => handleJustifyClick('tab3')} active={justifyActive === 'tab3'}>
                        Another link
                      </MDBTabsLink>
                    </MDBTabsItem>
                  </MDBTabs>
    
                  <MDBTabsContent>
                    <MDBTabsPane show={justifyActive === 'tab1'}>Tab 1 content</MDBTabsPane>
                    <MDBTabsPane show={justifyActive === 'tab2'}>Tab 2 content</MDBTabsPane>
                    <MDBTabsPane show={justifyActive === 'tab3'}>Tab 3 content</MDBTabsPane>
                  </MDBTabsContent>
                </>
              );
            }
          
        
    

Vertical

Stack your navigation by changing the flex item direction with the .flex-column utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., .flex-sm-column).

For proper layout, you may also need to use grid to adjust navs and content.

Home content
Profile content
Messages content
        
            
          import React, { useState } from 'react';
          import {   
            MDBTabs,
            MDBTabsItem,
            MDBTabsLink,
            MDBTabsContent,
            MDBTabsPane,
            MDBRow,
            MDBCol
          } from 'mdb-react-ui-kit';
  
          export default function App() {
            const [verticalActive, setVerticalActive] = useState('tab1');

            const handleVerticalClick = (value: string) => {
              if (value === verticalActive) {
                return;
              }
          
              setVerticalActive(value);
            };

            return (
              <>
                <MDBRow>
                  <MDBCol size='3'>
                    <MDBTabs pills className='flex-column text-center'>
                      <MDBTabsItem>
                        <MDBTabsLink onClick={() => handleVerticalClick('tab1')} active={verticalActive === 'tab1'}>
                          Home
                        </MDBTabsLink>
                      </MDBTabsItem>
                      <MDBTabsItem>
                        <MDBTabsLink onClick={() => handleVerticalClick('tab2')} active={verticalActive === 'tab2'}>
                          Profile
                        </MDBTabsLink>
                      </MDBTabsItem>
                      <MDBTabsItem>
                        <MDBTabsLink onClick={() => handleVerticalClick('tab3')} active={verticalActive === 'tab3'}>
                          Messages
                        </MDBTabsLink>
                      </MDBTabsItem>
                    </MDBTabs>
                  </MDBCol>
                  <MDBCol size='9'>
                    <MDBTabsContent>
                      <MDBTabsPane show={verticalActive === 'tab1'}>Home content</MDBTabsPane>
                      <MDBTabsPane show={verticalActive === 'tab2'}>Profile content</MDBTabsPane>
                      <MDBTabsPane show={verticalActive === 'tab3'}>Messages content</MDBTabsPane>
                    </MDBTabsContent>
                  </MDBCol>
                </MDBRow>
              </>
            );
          }
          
        
    

Pills with icons

Use one of 1541 icons and add it to the pills. See the icon docs to explore all the available icons.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
              import React, { useState } from 'react';
              import {
                MDBIcon,   
                MDBTabs,
                MDBTabsItem,
                MDBTabsLink,
                MDBTabsContent,
                MDBTabsPane
              } from 'mdb-react-ui-kit';
      
              export default function App() {
                const [iconsActive, setIconsActive] = useState('pill1');

                const handleIconsClick = (value: string) => {
                  if (value === iconsActive) {
                    return;
                  }
              
                  setIconsActive(value);
                };

                return (
                  <>
                    <MDBTabs pills className='mb-3'>
                      <MDBTabsItem>
                        <MDBTabsLink onClick={() => handleIconsClick('pill1')} active={iconsActive === 'pill1'}>
                          <MDBIcon fas icon='chart-pie' className='me-2' /> Sales
                        </MDBTabsLink>
                      </MDBTabsItem>
                      <MDBTabsItem>
                        <MDBTabsLink onClick={() => handleIconsClick('pill2')} active={iconsActive === 'pill2'}>
                          <MDBIcon fas icon='chart-line' className='me-2' /> Subscriptions
                        </MDBTabsLink>
                      </MDBTabsItem>
                      <MDBTabsItem>
                        <MDBTabsLink onClick={() => handleIconsClick('pill3')} active={iconsActive === 'pill3'}>
                          <MDBIcon fas icon='cogs' className='me-2' /> Settings
                        </MDBTabsLink>
                      </MDBTabsItem>
                    </MDBTabs>

                    <MDBTabsContent>
                      <MDBTabsPane show={iconsActive === 'pill1'}>Tab 1 content</MDBTabsPane>
                      <MDBTabsPane show={iconsActive === 'pill2'}>Tab 2 content</MDBTabsPane>
                      <MDBTabsPane show={iconsActive === 'pill3'}>Tab 3 content</MDBTabsPane>
                    </MDBTabsContent>
                  </>
                );
              }
            
        
    

Pills - API


Import

        
            
          import {
            MDBTabs,
            MDBTabsItem,
            MDBTabsLink,
            MDBTabsContent,
            MDBTabsPane
          } from 'mdb-react-ui-kit';
        
        
    

Properties

MDBTabs

Name Type Default Description Example
justify boolean false Sets equal width of the MDBTabs items <MDBTabs pills justify>...</MDBTabs>
fill boolean false Fills the available space in MDBTabs items <MDBTabs pills fill>...</MDBTabs>
pills boolean false Necessary to change the MDBTabs into pills <MDBTabs pills>...</MDBTabs>
ref React.Ref<any> A reference to the MDBTabs component <MDBTabs pills ref={someRef}>...</MDBTabs>

MDBTabsContent

Name Type Default Description Example
tag React.ComponentProps<any> 'div' Defines tag of the MDBTabsContent element <MDBTabsContent tag="section" />
ref React.Ref<any> '' A reference to the MDBTabsContent component <MDBCardHeader ref={someRef} />

MDBTabsItem

Name Type Default Description Example
ref React.Ref<any> A reference to the MDBTabsItem component <MDBTabsItem ref={someRef} />

MDBTabsPane

Name Type Default Description Example
tag React.ComponentProps<any> 'div' Defines tag of the MDBTabsPane element <MDBTabsPane tag="section" />
show boolean '' Defines MDBTabsPanes content is shown <MDBTabsPane show />
ref React.Ref<any> A reference to the MDBTabsPane component <MDBTabsPane ref={someRef} />