Favorites

cubic-bezier() CSS Function

cubic-bezier()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The cubic-bezier() easing function defines a custom easing curve with four numbers, controlling how a transition or animation speeds up and slows down.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The cubic-bezier() CSS function defines a custom easing curve for transitions and animations using a cubic Bézier curve. It controls how the speed of a change varies over time, for example starting slowly and finishing quickly, or overshooting the target and settling back. It is used with transition-timing-function, animation-timing-function and their shorthands.

The curve always starts at point (0, 0) and ends at (1, 1). The four numbers you provide are the coordinates of two control points, (x1, y1) and (x2, y2), which bend the curve between those ends. The x values represent time and must be between 0 and 1. The y values represent progress and can go outside that range: values above 1 make the animation overshoot, and values below 0 make it pull back before it starts. The common keywords are all cubic Bézier curves: ease is cubic-bezier(0.25, 0.1, 0.25, 1), ease-in is cubic-bezier(0.42, 0, 1, 1), ease-out is cubic-bezier(0, 0, 0.58, 1) and ease-in-out is cubic-bezier(0.42, 0, 0.58, 1).

/* Snappy deceleration */
.menu {
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Overshoot and settle, like a gentle spring */
.button:hover {
  transform: scale(1.1);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

Browser developer tools include a visual curve editor for cubic-bezier(), which makes it easy to experiment. For curves with many bounces, use linear() instead.

Interactive Demo

linear (for comparison)
the selected timing function
Demo Code
HTML Code
<div class="demo-lanes">
	linear (for comparison)
	<div class="demo-ref"></div>
	the selected timing function
	<div class="demo-element"></div>
</div>
CSS Code
@keyframes demo-ease {
	to { transform: translateX(220px); }
}
.demo-lanes {
	width: 300px;
	padding: 10px;
	box-sizing: border-box;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
	font-size: 12px;
	color: #666;
}
.demo-ref, .demo-element {
	width: 50px;
	height: 40px;
	margin: 4px 0 10px;
	border-radius: 6px;
	animation: demo-ease 2s infinite alternate;
}
.demo-ref {
	background: #c5c5c5;
	animation-timing-function: linear;
}
.demo-element {
	background: #f72585;
	animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
}

Syntax

cubic-bezier() = cubic-bezier( <number [0,1]>, <number>, <number [0,1]>, <number> )

Values

  • x1, y1The coordinates of the first control point. x1 must be between 0 and 1; y1 can be any number.
  • x2, y2The coordinates of the second control point. x2 must be between 0 and 1; y2 can be any number. y values outside 0 to 1 cause overshoot.

Example

<div class="wrap">
<h1>CSS cubic-bezier() examples</h1>
<div class="grid">
<div class="card">
<div class="track ease"><span class="ball"></span></div>
<div class="label">cubic-bezier(0.25, 0.1, 0.25, 1) /* ease */</div>
</div>
<div class="card">
<div class="track in"><span class="ball"></span></div>
<div class="label">cubic-bezier(0.7, 0, 0.84, 0)</div>
</div>
<div class="card">
<div class="track out"><span class="ball"></span></div>
<div class="label">cubic-bezier(0.16, 1, 0.3, 1)</div>
</div>
<div class="card">
<div class="track back"><span class="ball"></span></div>
<div class="label">cubic-bezier(0.34, 1.56, 0.64, 1) /* overshoot */</div>
</div>
</div>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* cubic-bezier() examples */
.track {
position: relative;
height: 44px;
border-radius: 22px;
background: #e2e8f0;
}

.ball {
position: absolute;
top: 6px;
left: 6px;
width: 32px;
height: 32px;
border-radius: 50%;
background: #2563eb;
animation: slide 2s infinite alternate;
}

@keyframes slide {
to { left: calc(100% - 38px); }
}

.ease .ball { animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1); }
.in .ball { animation-timing-function: cubic-bezier(0.7, 0, 0.84, 0); }
.out .ball { animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
.back .ball { animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS cubic-bezier() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.