Use our Tailwind CSS Checkbox built with Angular to allow multi-option selections on your website or applications.
Checkboxes play an important role in enabling users to select multiple options from a list. They should provide immediate feedback upon selection and be spaced adequately for ease of interaction.
Check out our Angular Checkbox example designed with Tailwind CSS. It's ideal for any application that requires multi-select capabilities.
You first need to import the DUICheckbox Module into your application module
Code
import { DUICheckbox } from "david-ui-angular"; @NgModule({ declarations: [AppComponent], imports: [BrowserModule, DUICheckbox], providers: [], bootstrap: [AppComponent], }) export class AppModule {}
Preview
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" [isChecked]="true"></dui-checkbox>
You can use different colors of the checkbox component by manipulating the color attribute of the component
Preview
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" [isChecked]="true"></dui-checkbox> <dui-checkbox color="red" [isChecked]="true"></dui-checkbox> <dui-checkbox color="purple" [isChecked]="true"></dui-checkbox>
You can add a label for the Checkbox component by passing the label prop to the Checkbox component.
Preview
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" label="Remember Me" [isChecked]="true"></dui-checkbox>
You can turn on/off the ripple effect for the Checkbox
Component using ripple
attribute.
Preview
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" label="Ripple Effect On" [isChecked]="true" [ripple]="true"></dui-checkbox> <dui-checkbox color="gray" label="Ripple Effect Off" [isChecked]="true" [ripple]="false"></dui-checkbox>
You can add custom icon for the Checkbox
Component when it's checked by using the dui-icon
element inside dui-checkbox
.
Preview
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" label="Favourite" [isChecked]="true" [useCustomIcon]="true"> <dui-icon> <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor"> <path fillRule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clipRule="evenodd" /> </svg> </dui-icon> </dui-checkbox>
You can disable the Checkbox component by passing the disabled prop to the Checkbox component.
Preview
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" label="Remember Me" [isChecked]="true" [disabled]="true"></dui-checkbox> <dui-checkbox color="gray" label="Remember Me" [disabled]="true"></dui-checkbox>
You can add any element inside dui-checkbox
. Here we used typography to make it look like a Link
Preview
I agree with the terms and condition
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray"> <dui-typography color="gray" variant="paragraph"> I agree with the <a href="https://www.david-ui-angular.com/docs/checkbox" class="text-blue-500">terms and condition</a> </dui-typography> </dui-checkbox>
Use the example below for a more complex usage of checkbox with label that contains some description.
Preview
You'll be able to login without password for 24 hours.
Code
<!-- Use DUI Checkbox in html file --> <dui-checkbox color="gray" label="Remember me"> <div> <dui-typography color="gray" variant="small" className="font-normal"> You'll be able to login without password for 24 hours. </dui-typography> </div> </dui-checkbox>
The following properties are available for dui-checkbox
Attribute | Type | Description | Default |
---|---|---|---|
label | string | Checkbox label | '' |
color | Color | change checkbox color | blue |
className | string | Add custom className for checkbox | '' |
size | boolean | Change checkbox size | md |
disabled | boolean | Disable checkbox | false |
containerClassName | string | Checkbox container class property | '' |
ripple | boolean | Toggle ripple effect in checkbox | true |
useCustomIcon | boolean | use custom icon in checkbox | false |