Open In App

Bootstrap 5 Select Sizing

Last Updated : 04 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Bootstrap 5 Select Sizing is used to choose form’s select small and large custom selects to match your different-sized text inputs. The large-sized select element used the class form-select-lg and the small-sized select uses the form-select-sm class.

Bootstrap 5 Select Sizing Class: The default size is medium size so we don’t need to put any class for that.

  • form-select-sm: This class is used to set the select input in small size.
  • form-select-lg: This class is used to set the select input in large size.

Syntax: The * can be replaceable with sm and lg according to your text-inputs size.

<select class="form-select form-select-*">
    ...
</select>

Example 1: In this example, we show the default and the large-sized using the “form-select-lg” class.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
    <!-- Bootstrap Javascript CDN -->
    <script src=
    </script>
    <script src=
    </script>
  
    <!-- Bootstrap CSS CDN -->
    <link rel="stylesheet" 
          href=
  
  
</head>
  
<body>
    <div class="m-3">
        <div class="geeksforgeeks">
            <h3 class="text-success">GeeksforGeeks</h3>
            <h4>Bootstrap 5 Select Sizing</h4>
        </div>
  
        <h5>Default Sized Select Element</h5>
        <select class="form-select">
            <option value="dsa">C/C++</option>
            <option value="dev">Java</option>
            <option value="cp">Rust</option>
            <option value="sd">Python</option>
        </select>
  
        <h5>Large Sized Select Element</h5>
        <select class="form-select form-select-lg">
            <option value="dsa">C/C++</option>
            <option value="dev">Java</option>
            <option value="cp">Rust</option>
            <option value="sd">Python</option>
        </select>
    </div>
</body>
  
</html>


Output:

Bootstrap 5 Select Sizing

Example 2: In this example, the small-sized select element is shown using the class “form-control-sm”.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
    <!-- Bootstrap Javascript CDN -->
    <script src=
    </script>
    <script src=
    </script>
  
    <!-- Bootstrap CSS CDN -->
    <link rel="stylesheet" 
          href=
  
  
</head>
  
<body>
    <div class="m-3">
        <div class="geeksforgeeks">
            <h3 class="text-success">GeeksforGeeks</h3>
            <h4>Bootstrap 5 Select Sizing</h4>
        </div>
  
        <h5>Default Sized Select Element</h5>
        <select class="form-select">
            <option value="dsa">C/C++</option>
            <option value="dev">Java</option>
            <option value="cp">Rust</option>
            <option value="sd">Python</option>
        </select>
  
        <h5>Small Sized Select Element</h5>
        <select class="form-select form-select-sm">
            <option value="dsa">C/C++</option>
            <option value="dev">Java</option>
            <option value="cp">Rust</option>
            <option value="sd">Python</option>
        </select>
    </div>
</body>
  
</html>


Output:

Bootstrap 5 Select Sizing

Reference: https://getbootstrap.com/docs/5.2/forms/select/#sizing



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads