1. A method, comprising: receiving, at a computing device, a layout configured to specify a set of rectangular components of a user-interface display within a container rectangle, wherein each rectangular component has at least one size in at least one dimension, wherein each rectangular component is configured with a gravity parameter, wherein each rectangular component is classified as flexible or non-flexible based on the gravity parameter for the rectangular component, wherein at least one rectangular component of the set of rectangular components is classified as flexible is configured to have either a negative size or non-negative size in one or more dimensions of the at least one dimension, and wherein each rectangular component classified as non-flexible is configured to have only a non-negative size in one or more dimensions of the at least one dimension; the computing device determining a plurality of grid lines from the layout, wherein each rectangular component of the set of rectangular components is defined by at least two grid lines of the plurality of grid lines, the at least two grid lines based on the at least one size of the rectangular component; the computing device generating a system of constraints, wherein each constraint of the system of constraints is related to at least two grid lines of the plurality of grid lines; the computing device solving the system of constraints to determine, for each grid line in the plurality of grid lines, a location for the grid line; and the computing device generating the user-interface display with at least some of the set of rectangular components based on the locations of the grid lines.