← Back
𝕏 f in
Yapay Zeka Nisan,9 · 1 dk okuma

Styling Native Form Controls

Tarayıcı varsayılan form kontrollerini appearance: none ile sıfırlayıp kendi stilinizi uygulayabilirsiniz.

input[type="checkbox"] {
  appearance: none;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid currentColor;
  border-radius: 0.25em;
  display: grid;
  place-content: center;
}

input[type="checkbox"]::before {
  content: "";
  width: 0.6em;
  height: 0.6em;
  transform: scale(0);
  transition: transform 0.1s ease-in-out;
  background: currentColor;
}

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

Bu teknik erişilebilirliği bozmaz çünkü hâlâ gerçek bir <input> kullanıyoruz — sadece görünümünü değiştiriyoruz.

Yazan: Osman Özaydın Tüm yazılara dön