Skip to content

andrewh0/okcss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ†— OK.css

Sensible styling defaults for your web page

Project page Β· Demo


OK.css is a classless CSS framework. Dropping it into your HTML will make your page look decent β€” no need to reference documentation, think about responsiveness, or account for browser differences as long as your markup is semantically-correct.

To use it, you can download the CSS file directly or add the following line to your HTML <head>:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/ok.min.css" />

Note that normalize.css is included in OK.css.

Modular imports

If you don't need all of OK.css, you can import individual modules to reduce file size:

File Size Description
ok.min.css ~19 KB Full framework (includes everything)
core.min.css ~7 KB Typography, colors, dark mode, code blocks, links, lists, images
forms.min.css ~12 KB Inputs, selects, textareas, buttons (requires core.min.css)
tables.min.css ~1 KB Table styling (requires core.min.css)

Example: Content-only site (documentation, blog, markdown)

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/core.min.css" />

Example: Content site with forms

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/core.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/forms.min.css" />

Example: Full framework with tables

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/core.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/forms.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/andrewh0/okcss@2/dist/tables.min.css" />

OK.css is somewhere between a CSS normalizer and a full-fledged framework like Bootstrap or Tailwind. It's great for blogs or small single-page applications, but might not be so great for large, interactive apps that require JavaScript or custom elements.

Development

Install dependencies with yarn install.

You can start a local server with yarn start. By default, the page will be available at http://localhost:5000.

Make updates to the CSS files in ./src/ and run yarn build to create minified versions in ./dist/:

  • src/core.css - Typography, colors, dark mode, normalize, code, links, lists, media
  • src/forms.css - Form inputs, selects, textareas, buttons
  • src/tables.css - Table styling
  • src/ok.css - Entry point that imports all modules

The build uses Lightning CSS for minification and autoprefixing. The version number in the CSS header is automatically synced from package.json.

This repo is set up with Netlify's continuous deployment. yarn deploy copies files into a .gitignored directory called _site and _site is hosted on Netlify.

Releasing

Releases are automated via GitHub Actions. When a PR is merged to main, a new version is released based on the label in the PR body.

How to release

  1. Create a PR with your changes
  2. In the PR body, check one of the version labels:
    • patch - Bug fixes and minor changes (1.0.0 β†’ 1.0.1)
    • minor - New features (1.0.0 β†’ 1.1.0)
    • major - Breaking changes (1.0.0 β†’ 2.0.0)
    • skip-release - No release needed
  3. Merge the PR to main
  4. GitHub Actions will automatically:
    • Bump the version in package.json
    • Update the version in CSS files
    • Create a git tag
    • Create a GitHub Release with assets
    • Update CHANGELOG.md
    • Comment on the PR with the released version

Prereleases

Use the next branch to build up changes for a major release without publishing to main.

  1. Create and push the next branch from main:

    git checkout main
    git pull
    git checkout -b next
    git push -u origin next
    
  2. Merge PRs into next instead of main. Each merge creates a prerelease version (e.g., 2.0.0-next.0, 2.0.0-next.1).

  3. When ready to release, merge next into main:

    git checkout main
    git merge next
    git push
    

    This creates the final release (e.g., 2.0.0).

Manual release (if needed)

Preview what would be released:

yarn release:dry

Create a release manually:

yarn release

Contributing

Pull requests are welcome! If you find a bug or have a feature request, please submit a GitHub issue.

Alternative features

Not all UI features can be implemented with classless CSS while remaining accessible and supported cross-browser. For more complex features, you may need to supplement this framework with additional HTML, CSS, or JavaScript.

Here are some suggestions for altering the behavior of certain elements.

Feature

Make tables scroll horizontally when they are wider than the main content width.

Desired behavior:

HTML table with horizontal scroll

Note: In OK.css, tables are set to display: table for accessibility reasons.

Implementation

Wrap the table in a <div> with overflow-x: scroll;:

<div style="overflow-x: scroll">
  <table>
  ...
  </table>
</div>

One caveat is that this can prevent the table heading from sticking when scrolling vertically.

About

πŸ†— Sensible styling defaults for your web page

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •