The above search box stays expanded when text has been entered, even when it loses focus, using plain CSS. If it's empty, it collapses back to a circle when it loses focus.

The trick is the :valid selector on an <input> element, with the property required="required" .