---json { "description": "Improve the emphasis of your component by adding onHover animation", "page_id": "jjtvm4r62zdl4dconm731", "title": "Hover animation" } --- ====== ComboStrap Styling - Hover Animations ====== ===== About ===== ''hover animation'' permits to add animations to your [[docs:block:block|block component]] when the mouse points an element (ie is ''hover''). ===== Syntax ===== To add an ''hover animation'', add a ''onHover'' attribute with the name of your animation. ===== Animation ===== ==== Float ==== When you want to add [[docs:styling:shadow|dynamic elevation]], you can use the ''float'' animation * On a [[docs:content:button|button]] * On an [[docs:content:image|image]] {{:docs:styling:subway_card_tile.png?onHover=float|}} ==== Grow ==== When you want to add a zoom-in effect, you can use the ''grow'' animation * [[docs:content:button|button]] * [[docs:content:icon|icon]] A zoom-in / grow animated icon - ==== Shadow==== You can use the [[docs:styling:shadow#syntax|shadow animation name]] to add a shadow on hover. A animated card with a shadow ===== Combination ===== ==== Float Shadow ==== You can combine the effects, example with ''float'' and a [[docs:styling:shadow|shadow]] A combo float shadow animated card Beware that if you replace the space by a minus, you get the ''float-shadow'' [[#hover.css|hover.css effect]]. A hover.css float-shadow animated card ===== Hover.css ===== You can also use [[https://ianlunn.github.io/Hover/|Hover.css]] animation. We support the ''hover.css''naming standard. Example: a [[:docs:content:button|button]] with an underline animated from left The library is not primary supported because: * there is some incompatibility with [[docs:theme:bootstrap|BootStrap]] * they require a commercial license if not for personal use. If you underline problems, you can also [[#custom|add your own]]. ===== Custom ===== ==== Custom: Bootstrap Class ==== If the animation name is not found, the name is applied as a class. You can then used all Bootstrap utility class to create an hover effect. Example from an [[:docs:content:button|normal button]] to a bigger one with the ''btn-lg'' [[https://getbootstrap.com/docs/5.0/components/buttons/|Bootstrap button class]] where ''lg'' means a ''larger button'' \\ \\ \\ ==== Custom: Bring it to Combostrap ==== The ''hover animation'' applies the name of the animation as a class to the component when the mouse is hover it. If you want to bring your animation to ''ComboStrap'': * create a CSS class rule to apply on hover. Example: A ''darken'' animation: .darken { opacity: 0.5; } * clone the [[https://github.com/ComboStrap/combo|combo repository]] git clone https://github.com/ComboStrap/combo * add the CSS rule to the [[https://github.com/ComboStrap/combo/tree/master/resources/snippet/style/onhover.css|onhover.css stylesheet]] * and apply a pull request. ==== Custom: UserStyle ==== If you want to create an animation for yourself, add the CSS class rules in the ''onhover'' [[:docs:theme:component-stylesheet|component stylesheet]] Example with the ''fade'' like background transition of [[https://ianlunn.github.io/Hover/|hover.css]]. * The CSS button.animated:hover { background-color: #FFF; color: #2098D1; transition-duration: 0.4s; transition-property: color, background-color; } button { background-color: #007bff; color: #FFF; border-color: #007bff; padding: .375rem .75rem; line-height: 1.5; border-radius: .25rem; } * In your page * Result: