# transition function (for custom components) This is a function that is useful to write custom components or extend the components with animations. ## Usage ```js import { transition } from "tailwindcss-stimulus-components" import { Controller } from "@hotwired/stimulus" class CustomController extends Controller { static targets = ['content'] static classes = ['enter', 'enterFrom', 'enterTo', 'leave', 'leaveFrom', 'leaveTo', 'toggle'] showContent() { transition(this.contentTarget, true, this.defaultOptions()) } hideContent() { transition(this.contentTarget, false, this.defaultOptions()) } defaultOptions() { return { enter: this.hasEnterClass ? this.enterClasses.join(' ') : 'transition ease-out duration-100', enterFrom: this.hasEnterFromClass ? this.enterFromClasses.join(' ') : 'transform opacity-0 scale-95', enterTo: this.hasEnterToClass ? this.enterToClasses.join(' ') : 'transform opacity-100 scale-100', leave: this.hasLeaveClass ? this.leaveClasses.join(' ') : 'transition ease-in duration-75', leaveFrom: this.hasLeaveFromClass ? this.leaveFromClasses.join(' ') : 'transform opacity-100 scale-100', leaveTo: this.hasLeaveToClass ? this.leaveToClasses.join(' ') : 'transform opacity-0 scale-95', toggleClass: this.hasToggleClass ? this.toggleClasses.join(' ') : 'hidden', } } } application.register('custom', CustomController) ``` The default animation attributes can be put in a controller like this so they can optionnaly be overwritten on an element by element basis ```html
Show Hide
```