---
layout: default
title: Sizing
title_tag: true
permalink: /examples/sizing/4.0/
---
{%- capture single_select -%}
{%- endcapture -%}
{%- capture multiple_select -%}
{%- endcapture -%}
Small
Select2 Options
{% assign field_name = "small-select2-options" %}
{% capture example_html %}
{{ single_select | replace: "single-select", field_name }}
{{ multiple_select | replace: "multiple-select", field_name }}
{% endcapture %}
{% capture example_js %}
$( '#{{ field_name }}-single-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
containerCssClass: 'select2--small',
dropdownCssClass: 'select2--small',
} );
$( '#{{ field_name }}-multiple-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
closeOnSelect: false,
containerCssClass: 'select2--small',
dropdownCssClass: 'select2--small',
} );
{% endcapture %}
{% include example.html %}
Bootstrap 5 Class
{% assign field_name = "small-bootstrap-class" %}
{% capture example_html %}
{{ single_select | replace: "single-select", field_name | replace: "form-select", "form-select form-select-sm" }}
{{ multiple_select | replace: "multiple-select", field_name | replace: "form-select", "form-select form-select-sm" }}
{% endcapture %}
{% capture example_js %}
$( '#{{ field_name }}-single-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
dropdownParent: $( '#{{ field_name }}-single-field' ).parent(),
} );
$( '#{{ field_name }}-multiple-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
closeOnSelect: false,
dropdownParent: $( '#{{ field_name }}-multiple-field' ).parent(),
} );
{% endcapture %}
{% include example.html %}
Large
Select2 Options
{% assign field_name = "large-select2-options" %}
{% capture example_html %}
{{ single_select | replace: "single-select", field_name }}
{{ multiple_select | replace: "multiple-select", field_name }}
{% endcapture %}
{% capture example_js %}
$( '#{{ field_name }}-single-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
containerCssClass: 'select2--large',
dropdownCssClass: 'select2--large',
} );
$( '#{{ field_name }}-multiple-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
closeOnSelect: false,
containerCssClass: 'select2--large',
dropdownCssClass: 'select2--large',
} );
{% endcapture %}
{% include example.html %}
Bootstrap 5 Class
{% assign field_name = "large-bootstrap-class" %}
{% capture example_html %}
{{ single_select | replace: "single-select", field_name | replace: "form-select", "form-select form-select-lg" }}
{{ multiple_select | replace: "multiple-select", field_name | replace: "form-select", "form-select form-select-lg" }}
{% endcapture %}
{% capture example_js %}
$( '#{{ field_name }}-single-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
dropdownParent: $( '#{{ field_name }}-single-field' ).parent(),
} );
$( '#{{ field_name }}-multiple-field' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
closeOnSelect: false,
dropdownParent: $( '#{{ field_name }}-multiple-field' ).parent(),
} );
{% endcapture %}
{% include example.html %}